Skip to content

ranquild/angular_redux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

angular_redux.dart

Bindings between Redux and Angular Dart.

Quick Start

Create a factory for your Store:

class CounterStoreFactory {
  static Store<CounterState> createStore(/* ... */) {
    return Store(/* ... */); 
  }
}

Use FactoryProvider to make the Store injectable:

@Component(
  /* ... */
  providers: [
    /* ... */
    FactoryProvider(Store, CounterStoreFactory.createStore)
  ],
)
class CounterAppComponent {
  /* ... */
}

Extend base SelectPipe to specify the State type:

@Pipe('select', pure: false)
class CounterSelectPipe extends SelectPipe<CounterState> {
  CounterSelectPipe(Store<CounterState> store, ChangeDetectorRef detector) : super(store, detector);
}

Use this pipe in your components:

@Component(
  /* ... */
  pipes: [
    CounterSelectPipe,
  ],
)
class CounterAppComponent {
  /* ... */
}

Add a selector method in the component to select a value from the Store:

class CounterAppComponent {
  /* ... */

  int getCount(CounterState state) => state.count;
}

Use select pipe in Angular templates to extract a value from the Store:

<div>
  {{ getCount | select }}
</div>

Component will be marked for check automatically when the State changes and the selector returns new value.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published