ConnectFluxAdapterStore<S extends Store> class

A class that can be used to make a flux.Store compatible with connectFlux without adding the Redux implementation.

The usage is the same as connectFlux with the FluxToReduxAdapterStore, but does not have the infrastructure for Redux dispatching.

Note: Because this adapter store does not have a real Redux reducer, a connected component cannot trigger actions. If the library in the position to have Redux components, this class should not be used (implementing FluxToReduxAdapterStore instead) and the Redux boilerplate should be added. If needed, however, a connected component can receive updates from this implementation (just not trigger them).

Example:

import 'package:w_flux/w_flux.dart' as flux;

class ExampleFluxStore extends flux.Store {
  FluxActions _actions

  String _valueFromState = 'Default Value';
  String get valueFromState => _valueFromState;

  ExampleFluxStore(this._actions) {
    triggerOnActionV2(_actions.fluxAction, _mutateValueFromState);
  }

  void _mutateValueFromState(String newValue) {
    _valueFromState = newValue;
  }
}

class FluxActions {
  final flux.Action<String> changeBackgroundColor = flux.Action();
}

FluxActions actions = FluxActions();
ExampleFluxStore store = ExampleFluxStore(actions);

ConnectFluxAdapterStore adapterStore = ConnectFluxAdapterStore<ExampleFluxStore, Null>(store, actions);

Related: connectFlux, FluxToReduxAdapterStore

Constructors

ConnectFluxAdapterStore(S store, dynamic actions, {List<Middleware<S>>? middleware})

Properties

hashCode int
The hash code for this object.
no setterinherited
onChange Stream<S>
A stream that emits the current state when it changes.
no setterinherited
reducer ↔ Reducer<S>
The Reducer for your Store. Allows you to get the current reducer or replace it with a new one if need be.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state → S
Returns the current state of the app
no setterinherited
store → S
A reference to an instantiated Flux store object that backs the adapter store.
final

Methods

dispatch(dynamic action) → dynamic
Runs the action through all provided Middleware, then applies an action to the state using the given Reducer. Please note: Middleware can intercept actions, and can modify actions or stop them from passing through to the reducer.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
teardown() Future
Closes down the Store so it will no longer be operational. Only use this if you want to destroy the Store while your app is running. Do not use this method as a way to stop listening to onChange state changes. For that purpose, view the onChange documentation.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited