An implementation of the ´BLoC´ (Business Logic Component) with Apple’s Combine framework.
BLoC is a business logic layer abstraction in which you input an Event and it outputs a State.
This abstraction contributes to the construction of reactive apps that respects the unidirectional data flow and have a single source of truth.
A Bloc from the CombineBloc package is a composite object that has a Subscriber which receives Event and a Publisher of State.
A closure is called inside the Bloc everytime a new Event is received by the Subscriber. This closure may emit a new State through the Publisher.
The key points are:
Inputs and outputs are implemented with event-processing operators
Dependencies must be injectable and platform agnostic
Combine Bloc
BLoC is a business logic layer abstraction in which you input an
Event
and it outputs aState
. This abstraction contributes to the construction of reactive apps that respects the unidirectional data flow and have a single source of truth. ABloc
from the CombineBloc package is a composite object that has aSubscriber
which receivesEvent
and aPublisher
ofState
. A closure is called inside the Bloc everytime a newEvent
is received by theSubscriber
. This closure may emit a newState
through thePublisher
.The key points are:
This package is inspired by the concept of BLoC proposed by Paolo Soares on DartConf 2018 and by Felix Angelov’s Flutter Bloc State Management Library
Installation
Add this project on your
Package.swift
Usage example
This package has three use case examples implemented:
Counter Bloc example
Counter Events
Counter State
Counter Bloc
Release History
Meta
Wellington Soares
Distributed under the MIT license. See
LICENSE
for more information.