applyOnSet<T> static method
void Function(T)
applyOnSet<T>(
- void next(
- T
- LxReactive reactive,
- LevitReactiveChange<
T> change
Applies the onSet chain to a value mutation.
Implementation
static void Function(T) applyOnSet<T>(
void Function(T) next,
LxReactive reactive,
LevitReactiveChange<T> change,
) {
if (!LevitReactiveMiddleware.hasSetMiddlewares) return next;
void Function(dynamic) current = (dynamic v) => next(v as T);
for (final mw in LevitReactiveMiddleware._middlewares.reversed) {
if (mw.onSet != null) {
current = mw.onSet!(
current, reactive, change as LevitReactiveChange<dynamic>);
}
}
return (T val) => current(val);
}