SessionScope class
Keeps every SessionScoped controller and registered holder pointed at the session that is authenticated right now.
Static because everything it coordinates is process-wide: Auth.stateNotifier
is one notifier per guard and Magic.controllers is one registry. A second
instance would listen to the same notifier and reset everything twice per
identity change.
attach is explicit: no core provider calls it, because it must be the
LAST Auth.stateNotifier listener so realtime, polling and locale already
point at the new session before its data is refetched.
@override
Future<void> boot() async {
SessionScope.identity = () => Auth.check() ? '${Auth.id()}:$teamId' : null;
SessionScope.attach();
}
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- identity ↔ String? Function()
-
Reads the identity that owns the data in scope, or null while nobody is
signed in.
getter/setter pair
- isAttached → bool
-
Whether a subscription to auth state changes is currently active.
no setter
Static Methods
-
attach(
) → void - Records the identity the app boots with, then resets every scoped holder on each later identity change.
-
detach(
) → void - Unsubscribes from auth state changes and forgets the recorded identity.
-
register(
SessionScoped holder) → void -
Adds a non-controller
holder(a repository) to every later reset. Controllers need no registration; they are found inMagic.controllers. -
sync(
) → void - Compares the current identity with the recorded one and, on a change to a non-null identity, resets every scoped controller and holder in place.
-
unregister(
SessionScoped holder) → void -
Removes
holderfrom later resets; call it when the holder is disposed.