Selector<T> constructor
Selector<T> ({
- required String key,
- required GetRecoilValue<
T, dynamic> getValue,
Creates a Selector, which represents a piece of readable state
- Define a unique
key
in order to identify the relative atom - Use
getValue
in order to get a readable value of a created Atom. The return type ofgetValue
is a dynamic, so be sure to cast with the return type of the Atom you're reading from. That's because in a Selector it's possible to get the value of different Atom
final fooSelector = Selector(
key: 'foo_selector_key',
getValue: (getValue) {
final value = getValue(fooAtom) as YourAtomType;
// Manipulate your value
return manipulatedValue;
},
);
Implementation
Selector({
required String key,
required this.getValue,
}) : super(key: key);