Molecule<T> constructor
Molecule<T> ({})
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.
Returns the newly created Molecule.
Implementation
Molecule(
{required List<Atom> atoms,
required T Function(Atom<E>? Function<E>(String getAtom)) computer,
required String key})
: _atoms = atoms,
_computer = computer,
key = key {
_atoms.forEach((atom) {
atom.stateStream.listen((value) {
_computeValue();
});
});
_computeValue();
}