Skip to content

Easily move your whole logic into separated isolated

License

Notifications You must be signed in to change notification settings

kitsuniru/isolated_logic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Isolated Logic

Install

stable: dart pub add isolated_logic

Features

  • Easy: Just wrap your existing controllers into wrapper and it's ready to use
  • Solution-agnostic: Supports any state management solution that can emit states as Stream<State>
  • Interopability: Supports StreamBuilders and ValueListenableBuilder's
  • Low overhead: There's only ~5% loss on speed due de/serialization between isolates
  • Single-for-all Abstraction: Use a multiple business logic approaches under a single IsolatedController abstraction

Usage

Example (wrapper for BLoC):

class PrimesBlocIsolated extends IsolatedController<PrimesBLoC, AppDependencies, PrimesEvent, int> {
  /// Creation of the target controller can be declared as argument
  /// or passed like a 'super' value;
  PrimesBlocIsolated({required super.createController});

  /// [controllerLifecycle] describes lifecycle of the controller that was instantiated at
  /// separated Isolate
  @override
  ControllerLifecycleHandler<PrimesBLoC> get controllerLifecycle => ControllerLifecycleHandler(
        stateStream: (controller) => controller.stream,
        dispose: (controller) => controller.close(),
      );


  /// This events will be handled in separated isolate
  ///
  /// All emited states by these events will be routed into main isolate
  /// via bus
  void increment() => isolateHandle((controller) => controller.add(const PrimesEvent.increment()));
  void decrement() => isolateHandle((controller) => controller.add(const PrimesEvent.decrement()));
}

2023, Archie Kitsushimo

About

Easily move your whole logic into separated isolated

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages