UseContext<T extends ReactterContext> constructor

UseContext<T extends ReactterContext>({
  1. String? id,
  2. ReactterContext? context,
})

Implementation

UseContext({
  this.id,
  this.context,
}) : super(context) {
  if (context != null) {
    Reactter.one(context, Lifecycle.destroyed, (_, __) => dispose);
  }

  _getInstance();

  Reactter.on(
    ReactterInstance<T>(id),
    Lifecycle.destroyed,
    _onInstance,
  );

  if (instance != null) return;

  Reactter.on(
    ReactterInstance<T>(id),
    Lifecycle.initialized,
    _onInstance,
  );
  Reactter.on(
    ReactterInstance<T>(id),
    Lifecycle.willMount,
    _onInstance,
  );
}