lazyState<T extends ReactterState> method

T lazyState<T extends ReactterState>(
  1. T stateFn(),
  2. Object instance
)

It is used to load a ReactterState lazily and attach it to a specific instance.

Implementation

T lazyState<T extends ReactterState>(T stateFn(), Object instance) {
  final zone = ReactterZone();
  try {
    return stateFn();
  } finally {
    zone.attachInstance(instance);
  }
}