Swiftpack.co -  brendenk1/Synthesis as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
brendenk1/Synthesis
The combination of ideas to form a theory or system.
.package(url: "https://github.com/brendenk1/Synthesis.git", from: "2.2.0")

Synthesis

noun: The combination of ideas to form a theory or system.

After working with Apple's native frameworks Combine and SwiftUI, several different state and data flow ideas have been suggested and tried.

Two main objectives to this system:

  • Single source of truth over time
  • Consistent, reliable data flow

While nothing here is novel, it is a selection of various approaches distilled to a single method.

Components

  • Action

noun: the fact or process of doing something, typically to achieve an aim

These objects are responsible for connecting a Kernel to a Connector object

  • Connector

noun: a thing which links two or more things together

These objects are responsible for connecting outside sources to a subscription via a publisher

  • ErrorSubscription

subscription noun: the action of making or agreeing to make an advance payment in order to receive something

This specialized Subscription is a part of Combine.Subscribers that allow for the receipt of errors

  • Format

noun: a defined structure for the processing or display of data

These objects provide definitions on how to present data

  • Kernel

noun: the most basic level or core

These objects represent the source of truth over time

  • Manager

noun: a system that controls or organizes processes

These objects represent formatted values for presentation

Diagram

+-------------------------------------------------------------------------+
|                                                                         |
|                                                                         |
|                                     +--------------------- UI           |
|                                     |                      ^            |
|                                     |                      |            |
|                                     +--------------------- Manager      |
|                                     |                      ^            |
|                                     v                      |            |
|                                   Action                   Format       | 
|                                     |                      ^            |
|                                     v                      |            |
|       Outside Sources ----------> Connector -------------> Kernel       |
|                                                                         |
|                                                                         |
|                                                                         |
+-------------------------------------------------------------------------+

Connectors

  • SetValueConnector

A default connect suitable for setting a value on a Kernel instance.

Register

noun: a location in a store of data, used for a specific purpose and with quick access time

This object is used to store a collection of unique elements with fast access. Methods are provided to update registry with both new and existing elements, remove elements, clear all elements, and find elements.

For example:

let register: Register<Int> = Register()
register.updateRegister(withElement: 1)
register.updateRegister(withElement: 2)

do {
    let value = try register.findRegistryItem(matching: 2)
} catch {
    print(error)
}

GitHub

link
Stars: 1
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics