Skip to content

davidmarne/built_redux_repatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Repatch

By adding a single repatch action dispatcher, one can dispatch builder functions as an action payload. This means one does not have to create an action dispatcher for every reducer, they can dispatch reducers directly.

Example

Add an action dispatcher:

abstract class CounterActions extends ReduxActions {
  ActionDispatcher<Repatch<Counter, CounterBuilder>> repatchDispatcher;

  // factory to create on instance of the generated implementation of CounterActions
  CounterActions._();
  factory CounterActions() => new _$CounterActions();
}

Pass repatchReducer to you store as the reducer

var store = new Store<Counter, CounterBuilder, CounterActions>(
  createRepatchReducer<Counter, CounterBuilder>(),
  new Counter(),
  new CounterActions(),
);

Dispatch the repatch

// increments count
store.actions.repatchDispatcher((s, b) => b.count++);
// decrements count
store.actions.repatchDispatcher((s, b) => b.count--);

About

repatch for built_redux

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages