Skip to content

Adding Suspendible support #10

@shaps80

Description

@shaps80

Adding Suspendible support

Introduction

Composed should introduce the concept of a Section being Suspendible in order to prevent user-driven events triggering duplicate events in UIKit.

Motivation

ManagedSection is backed by CoreData and currently provides dedicated functions for suspending updates in order to support user-driven events (e.g. reordering).

However the general pattern used by Composed is to 'discover' features through the use of a protocol. To bring this inline with the rest of Composed, I'm proposing we introduce a protocol to add support for this:

public protocol Suspendible {
    func suspend()
    func resume()
}

In addition I feel we should add similar methods to the appropriate Coordinator's:

This is just to provide a simple convenience for the API consumer. The implementation would be:

extension CollectionCoordinator {
    func suspend() {
        sectionProvider.sections
            .compactMap { $0 as? Suspendible }
            .forEach { $0.suspend() }
    }

    func resume() {
        sectionProvider.sections
            .compactMap { $0 as? Suspendible }
            .forEach { $0.resume() }
    }
}

Currently only ManagedSection would implement this protocol however formalising this approach allows custom Section's to piggy-back on this behaviour as well.

Source compatibility

This should be purely additive.

Alternatives considered

N/A

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions