Molecule<T> class Null safety

A Molecule is a derived state from one or multiple Atoms. This is a generic class which allows it to be used very dynamically.

Example usage:

var myMolecule = Molecule<int>(
  atomKeys: ['someAtom'],
  computer: (atoms) => atoms.values.fold<int>(
    0, (previousValue, element) => previousValue + element.state),
  key: 'myMolecule'));
myMolecule.stateStream.listen((state) => print(state));

Constructors

Molecule({required List<Atom> atoms, required T computer(Atom<E>? (String getAtom)), required String key})
Constructor. atoms the Atoms to be used when computing this Molecule's value. computer the function that computes this Molecule's value. key this Molecule's globally unique key.

Properties

hashCode int
The hash code for this object.
read-onlyinherited
key String
A globally unique key. Usually the same as the name of this Molecule.
latefinal
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
state → T
Get the state of this Molecule.
read-only
stateStream Stream<T>
A broadcast stream that can be listened to. Whenever the state of this Molecule changes a new event will be emited on this stream providing the listener with the new state.
read-only

Methods

dispose() → void
The dispose method should always be called before this Molecule is destroyed. It will close _controller. Think of this as a destructor that you have to manually call.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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