Skip to content

2.0.0

Latest
Compare
Choose a tag to compare
@andersio andersio released this 08 Mar 18:14
· 4 commits to develop since this release

This is the first stable release of Loop 2.0. It requires Swift 5.2, and supports CocoaPods, Carthage and Swift Package Manager (tools version 5.2).

API consolidation

Introduce Loop, a thread-safe implementation as the source of truth for your unidirectional data flows.

It is renamed from the v1.0 FeedbackLoop, and merged with features from the experimental compositional Store. Note that Loop now starts as it is initialised — start() and stop() previously provided by FeedbackLoop are now no-op and are officially deprecated.

API changes

New feedback variants

Loop now provides two new feedback variants:

  • whenBecomesTrue(_:effects:)

    Given a predicate over the loop state, it spawns an effect with a snapshot of the state, when a positive edge is observed from the the predicate output. It automatically cancels any outstanding effect if a negative edge is observed.

  • firstValueAfterNil(_:effects:)

    Given a transform over the loop state, it spawns an effect with the first non-nil value from the transform output. It automatically cancels any outstanding effect if any nil is observed.

Deprecated feedback variants

The aforementioned feedback variants are intended to replace predicate: as a standard offering in Loop.

We believe that the new variants provide more specialised semantics for the purpose of application development. Most importantly, from the production experience of Loop observed, we are confident that these are more flexible defaults to adapt to the variety in state modelling complexity (e.g., from sum type FSM, to product of sums).

Scoped loops

You can now create scoped loops through Loop.scoped to create lens of your root loop for injecting into different areas of your application.

Note on the scheduler-bound loop API

The scheduler-bound loop API — instantiated via Property.init or SignalProducer.system — has been deprecated since Loop 1.0. They may be removed in the next major release.