mobx public API
This reference is generated from the resolved exports of package:mobx/mobx.dart, including export filters and explicitly declared public members. Inherited Dart and Flutter members follow their platform contracts. Start with the learning path for guided examples, or API families to choose the right abstraction. Low-level exports support adapters and generated code; exporting a symbol does not make it the best starting point for an application.
Action
Import: package:mobx/mobx.dart
class Action with DebugCreationStackSee the API families guide for usage and ownership. This declaration is part of the public export surface.
Action
Action(Function fn, {ReactiveContext? context, String? name})Creates an action that encapsulates all the mutations happening on the observables.
Wrapping mutations inside an action ensures the depending observers are only notified when the action completes. This is useful to silent the notifications when several observables are being changed together. You will want to run your reactions only when all the mutations complete. This also helps in keeping the state of your application consistent.
You can give a debug-friendly [name] to identify the action.
var x = Observable(10);
var y = Observable(20);
var total = Observable(0);
autorun((){
print('x = ${x}, y = ${y}, total = ${total}');
});
var totalUp = Action((){
x.value++;
y.value++;
total.value = x.value + y.value;
}, name: 'adder');Even though we are changing 3 observables (x, y and total), the [autorun()] is only executed once. This is the benefit of action. It batches up all the change notifications and propagates them only after the completion of the action. Actions can also be nested inside, in which case the change notification will propagate when the top-level action completes.
name
String nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String get nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
call
dynamic call([List<dynamic> args = const [], Map<String, dynamic>? namedArgs])Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
toString
String toString()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ActionController
Import: package:mobx/mobx.dart
class ActionControllerActionController is used to define the start/end boundaries of code which should be wrapped inside an action. This ensures all observable mutations are neatly encapsulated.
You would rarely need to use this directly. This is primarily meant for the mobx_codegen package.
ActionController
ActionController({ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String get nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
startAction
ActionRunInfo startAction({String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
endAction
void endAction(ActionRunInfo info)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ActionRunInfo
Import: package:mobx/mobx.dart
class ActionRunInfoSee the API families guide for usage and ownership. This declaration is part of the public export surface.
ActionRunInfo
ActionRunInfo({required String name, DateTime? startTime, Derivation? prevDerivation, bool prevAllowStateChanges = true})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
prevDerivation
Derivation? prevDerivationUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
prevAllowStateChanges
bool prevAllowStateChangesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
startTime
DateTime? startTimeUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
prevDerivation
Derivation? get prevDerivationUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
prevAllowStateChanges
bool get prevAllowStateChangesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String get nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
startTime
DateTime? get startTimeUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ActionSpyEvent
Import: package:mobx/mobx.dart
class ActionSpyEvent extends SpyEventSee the API families guide for usage and ownership. This declaration is part of the public export surface.
ActionSpyEvent
ActionSpyEvent({required String name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
AsyncAction
Import: package:mobx/mobx.dart
class AsyncActionAsyncAction uses a [Zone] to keep track of async operations like [Future], timers and other kinds of micro-tasks.
You would rarely need to use this class directly. Instead, use the @action annotation along with the mobx_codegen package.
AsyncAction
AsyncAction(String name, {ReactiveContext? context})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
run
Future<R> run<R>(Future<R> Function() body)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
Atom
Import: package:mobx/mobx.dart
class Atom with DebugCreationStackSee the API families guide for usage and ownership. This declaration is part of the public export surface.
Atom
Atom({String? name, dynamic Function()? onObserved, dynamic Function()? onUnobserved, ReactiveContext? context})Creates a simple Atom for tracking its usage in a reactive context. This is useful when you don't need the value but instead a way of knowing when it becomes active and inactive in a reaction.
Use the [onObserved] and [onUnobserved] handlers to know when the atom is active and inactive respectively. Use a debug [name] to identify easily.
context
ReactiveContext contextUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isBeingObserved
bool isBeingObservedUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
hasObservers
bool hasObserversUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
context
ReactiveContext get contextUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String get nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isBeingObserved
bool get isBeingObservedUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
hasObservers
bool get hasObserversUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
reportObserved
void reportObserved()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
reportChanged
void reportChanged()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
onBecomeObserved
void Function() onBecomeObserved(void Function() fn)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
onBecomeUnobserved
void Function() onBecomeUnobserved(void Function() fn)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
toString
String toString()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
AtomSpyReporter
Import: package:mobx/mobx.dart
extension AtomSpyReporter on AtomSee the API families guide for usage and ownership. This declaration is part of the public export surface.
reportRead
void reportRead()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
reportWrite
void reportWrite<T>(T newValue, T oldValue, void Function() setNewValue, {bool Function(T?, T?)? equals, bool? useDeepEquality})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
BoolExtension
Import: package:mobx/mobx.dart
extension BoolExtension on boolSee the API families guide for usage and ownership. This declaration is part of the public export surface.
obs
Observable<bool> obs({ReactiveContext? context, String? name})turns a bool into Observable
ChangeNotification
Import: package:mobx/mobx.dart
class ChangeNotification<T>See the API families guide for usage and ownership. This declaration is part of the public export surface.
ChangeNotification
ChangeNotification<T>({OperationType? type, T? newValue, T? oldValue, dynamic object})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
type
OperationType? typeOne of add | update | delete
oldValue
T? oldValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
newValue
T? newValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
object
dynamic objectUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
type
OperationType? get typeUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
oldValue
T? get oldValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
newValue
T? get newValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
object
dynamic get objectUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
newValue
set newValue(T? value)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
object
set object(dynamic value)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
Computed
Import: package:mobx/mobx.dart
class Computed<T> extends Atom implements Derivation, ObservableValue<T>See the API families guide for usage and ownership. This declaration is part of the public export surface.
Computed
Computed<T>(T Function() fn, {String? name, ReactiveContext? context, bool Function(T?, T?)? equals, bool? keepAlive})Creates a computed value with an optional [name].
The passed in function: [fn], is used to give back the computed value. Computed values can depend on other observables and computed values! This makes them both an observable and an observer. Computed values are also referred to as derived-values because they inherently derive their value from other observables. Don't underestimate the power of the computed. They are possibly the most powerful observables in your application.
A computed's value is read with the value property.
It is possible to override equality comparison (when deciding whether to notify observers) by providing an [equals] comparator.
[keepAlive] This avoids suspending computed values when they are not being observed by anything. Can potentially create memory leaks.
var x = Observable(10);
var y = Observable(10);
var total = Computed((){
return x.value + y.value;
});
x.value = 100; // recomputes total
y.value = 100; // recomputes total again
print('total = ${total.value}'); // prints "total = 200"A computed value is cached and it recomputes only when the dependent observables actually change. This makes them fast and you are free to use them throughout your application. Internally MobX uses a 2-phase change propagation that ensures no unnecessary computations are performed.
equals
bool Function(T?, T?)? equalsUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
errorValue
MobXCaughtException? errorValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
value
T valueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
equals
bool Function(T?, T?)? get equalsUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
errorValue
MobXCaughtException? get errorValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
value
T get valueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
computeValue
T? computeValue({required bool track})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
observe
void Function() observe(void Function(ChangeNotification<T>) handler, {bool? fireImmediately})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
toString
String toString()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ComputedMethod
Import: package:mobx/mobx.dart
class ComputedMethodInternal class only used for code-generation with mobx_codegen.
During code-generation, this type is detected to identify a Computed
ComputedMethod
ComputedMethod({bool? keepAlive})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
keepAlive
bool? keepAliveUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
keepAlive
bool? get keepAliveUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ComputedValueSpyEvent
Import: package:mobx/mobx.dart
class ComputedValueSpyEvent extends SpyEventSee the API families guide for usage and ownership. This declaration is part of the public export surface.
ComputedValueSpyEvent
ComputedValueSpyEvent(dynamic object, {required String name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ConditionalAction
Import: package:mobx/mobx.dart
extension ConditionalAction on ReactiveContextSee the API families guide for usage and ownership. This declaration is part of the public export surface.
conditionallyRunInAction
void conditionallyRunInAction(void Function() fn, Atom atom, {String? name, ActionController? actionController})Only run within an action if outside a batch [fn] is the function to execute. Optionally provide a debug-[name].
Derivation
Import: package:mobx/mobx.dart
abstract class DerivationSee the API families guide for usage and ownership. This declaration is part of the public export surface.
Derivation
Derivation()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
errorValue
MobXCaughtException? errorValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String get nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
errorValue
MobXCaughtException? get errorValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
Dispose
Import: package:mobx/mobx.dart
typedef Dispose = void Function()See the API families guide for usage and ownership. This declaration is part of the public export surface.
DoubleExtension
Import: package:mobx/mobx.dart
extension DoubleExtension on doubleSee the API families guide for usage and ownership. This declaration is part of the public export surface.
obs
Observable<double> obs({ReactiveContext? context, String? name})turns a double into Observable
EndedSpyEvent
Import: package:mobx/mobx.dart
class EndedSpyEvent extends SpyEventSee the API families guide for usage and ownership. This declaration is part of the public export surface.
EndedSpyEvent
EndedSpyEvent({required String type, required String name, Duration? duration})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
EqualityComparer
Import: package:mobx/mobx.dart
typedef EqualityComparer<in T> = bool Function(T?, T?)See the API families guide for usage and ownership. This declaration is part of the public export surface.
FutureStatus
Import: package:mobx/mobx.dart
enum FutureStatusSee the API families guide for usage and ownership. This declaration is part of the public export surface.
FutureStatus
FutureStatus()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
pending
FutureStatus pendingUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
rejected
FutureStatus rejectedUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
fulfilled
FutureStatus fulfilledUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
values
List<FutureStatus> valuesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
pending
FutureStatus get pendingUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
rejected
FutureStatus get rejectedUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
fulfilled
FutureStatus get fulfilledUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
values
List<FutureStatus> get valuesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
IntExtension
Import: package:mobx/mobx.dart
extension IntExtension on intSee the API families guide for usage and ownership. This declaration is part of the public export surface.
obs
Observable<int> obs({ReactiveContext? context, String? name})turns an int into Observable
Interceptable
Import: package:mobx/mobx.dart
abstract class Interceptable<T>See the API families guide for usage and ownership. This declaration is part of the public export surface.
Interceptable
Interceptable<T>()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
intercept
void Function() intercept(WillChangeNotification<T>? Function(WillChangeNotification<T>) interceptor)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
Interceptor
Import: package:mobx/mobx.dart
typedef Interceptor<inout T> = WillChangeNotification<T>? Function(WillChangeNotification<T>)See the API families guide for usage and ownership. This declaration is part of the public export surface.
Interceptors
Import: package:mobx/mobx.dart
class Interceptors<T> extends NotificationHandlers<WillChangeNotification<T>>Stores the intercept-handlers that have been attached to a specific Observable.
When observableInstance.intercept(handler) is invoked, the passed-in handler is stored inside the Interceptors<T>. This is an internal class and should not be used directly.
Interceptors
Interceptors<T>(ReactiveContext context)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
add
void Function() add(WillChangeNotification<T>? Function(WillChangeNotification<T>) handler)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
interceptChange
WillChangeNotification<T>? interceptChange(WillChangeNotification<T> change)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ListChange
Import: package:mobx/mobx.dart
class ListChange<T>Stores the change related information when items was modified, added or removed from [list].
The [elementChanges] object stores change mappings for the indexes of changed elements. The [rangeChanges] object stores mappings of the changed ranges to the indexes of the first elements of this ranges. These two objects cannot overlap (cannot contain the same indexes of changed elements), in most cases only one of them will be defined.
ListChange
ListChange<T>({required ObservableList<T> list, List<ElementChange<T>>? elementChanges, List<RangeChange<T>>? rangeChanges})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
list
ObservableList<T> listUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
elementChanges
List<ElementChange<T>>? elementChangesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
rangeChanges
List<RangeChange<T>>? rangeChangesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
list
ObservableList<T> get listUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
elementChanges
List<ElementChange<T>>? get elementChangesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
rangeChanges
List<RangeChange<T>>? get rangeChangesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ListChangeListener
Import: package:mobx/mobx.dart
typedef ListChangeListener<in TNotification> = void Function(ListChange<TNotification>)See the API families guide for usage and ownership. This declaration is part of the public export surface.
Listenable
Import: package:mobx/mobx.dart
abstract class Listenable<TNotification>See the API families guide for usage and ownership. This declaration is part of the public export surface.
Listenable
Listenable<TNotification>()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
observe
void Function() observe(void Function(TNotification) listener, {bool fireImmediately = false})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
Listener
Import: package:mobx/mobx.dart
typedef Listener<in TNotification> = void Function(TNotification)See the API families guide for usage and ownership. This declaration is part of the public export surface.
Listeners
Import: package:mobx/mobx.dart
class Listeners<TNotification> extends NotificationHandlers<TNotification>Stores the handler functions that have been attached via [Observable.observe] method This is an internal class and should not be used directly.
Listeners
Listeners<TNotification>(ReactiveContext context)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
add
void Function() add(void Function(TNotification) handler)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
notifyListeners
void notifyListeners(TNotification change)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
MakeObservable
Import: package:mobx/mobx.dart
class MakeObservableInternal class only used for code-generation with mobx_codegen.
During code-generation, this type is detected to identify an Observable [readOnly] indicates that the field is only modifiable within the Store. It is possible to override equality comparison of new values with [equals].
bool _alwaysNotEqual(_, __) => false;
@MakeObservable(equals: _alwaysNotEqual)
String alwaysNotifyObservable = 'hello';
bool _equals(oldValue, newValue) => oldValue == newValue;
@MakeObservable(equals: _equals)
String withEquals = 'world';MakeObservable
MakeObservable({bool readOnly = false, Function? equals, bool useDeepEquality = true})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
readOnly
bool readOnlyUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
equals
Function? equalsA [Function] to use check whether the value of an observable has changed.
Must be a top-level or static [Function] that takes two arguments and returns a [bool]. The arguments are the old value and the new value of the observable. If the function returns true, the values are equal and no reaction is triggered. If the function returns false, the value has changed and reactions are notified. If no function is provided, the default behavior is to only trigger if : oldValue != newValue.
useDeepEquality
bool useDeepEqualityBy default, MobX uses the == to compare the previous value. This is fine for primitives, but for Iterable and Map, you may want to use a deep equality on collections. When using deep equal, no reaction will occur if all elements are equal.
readOnly
bool get readOnlyUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
equals
Function? get equalsUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
useDeepEquality
bool get useDeepEqualityUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
MapChange
Import: package:mobx/mobx.dart
class MapChange<K, V>Stores the information related to changes happening in an [ObservableMap]. This is used when firing the change notifications to all the listeners
MapChange
MapChange<K, V>({OperationType? type, K? key, V? newValue, V? oldValue, required ObservableMap<K, V> object})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
type
OperationType? typeUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
key
K? keyUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
newValue
V? newValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
oldValue
V? oldValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
object
ObservableMap<K, V> objectUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
type
OperationType? get typeUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
key
K? get keyUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
newValue
V? get newValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
oldValue
V? get oldValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
object
ObservableMap<K, V> get objectUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
MapChangeListener
Import: package:mobx/mobx.dart
typedef MapChangeListener<in K, in V> = void Function(MapChange<K, V>)See the API families guide for usage and ownership. This declaration is part of the public export surface.
MobXCaughtException
Import: package:mobx/mobx.dart
class MobXCaughtException extends MobXExceptionThis captures the stack trace when user-land code throws an exception
MobXCaughtException
MobXCaughtException(Object exception, {required StackTrace stackTrace})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
exception
Object exceptionUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
stackTrace
StackTrace? stackTraceUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
exception
Object get exceptionUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
stackTrace
StackTrace? get stackTraceUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
MobXCyclicReactionException
Import: package:mobx/mobx.dart
class MobXCyclicReactionException extends MobXExceptionThis exception would be fired when an reaction has a cycle and does not stabilize in [ReactiveConfig.maxIterations] iterations
MobXCyclicReactionException
MobXCyclicReactionException(String message)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
MobXException
Import: package:mobx/mobx.dart
class MobXException extends Error implements ExceptionAn Exception class to capture MobX specific exceptions
MobXException
MobXException(String message)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
message
String messageUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
message
String get messageUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
message
set message(String value)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
toString
String toString()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
Observable
Import: package:mobx/mobx.dart
class Observable<T> extends Atom implements Interceptable<T>, Listenable<ChangeNotification<T>>, ObservableValue<T>See the API families guide for usage and ownership. This declaration is part of the public export surface.
Observable
Observable<T>(T initialValue, {String? name, ReactiveContext? context, bool Function(T?, T?)? equals})Create an observable value with an [initialValue] and an optional [name]
Observable values are tracked inside MobX. When a reaction uses them they are implicitly added as a dependency of the reaction. When its value changes the linked reaction is re-triggered.
An Observable's value is read with the value property.
It is possible to override equality comparison of new values with [equals].
var x = Observable(10);
var message = Observable('hello');
print('x = ${x.value}'); // read an Observable's valueequals
bool Function(T?, T?)? equalsUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
value
T valueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
nonObservableValue
T nonObservableValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
equals
bool Function(T?, T?)? get equalsUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
value
T get valueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
nonObservableValue
T get nonObservableValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
value
set value(T value)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
observe
void Function() observe(void Function(ChangeNotification<T>) listener, {bool fireImmediately = false})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
intercept
void Function() intercept(WillChangeNotification<T>? Function(WillChangeNotification<T>) interceptor)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
toString
String toString()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableBoolExtension
Import: package:mobx/mobx.dart
extension ObservableBoolExtension on Observable<bool>See the API families guide for usage and ownership. This declaration is part of the public export surface.
toggle
void toggle()lets you toggle the internal value of ObservableBool
ObservableFuture
Import: package:mobx/mobx.dart
class ObservableFuture<T> implements Future<T>, ObservableValue<T?>See the API families guide for usage and ownership. This declaration is part of the public export surface.
ObservableFuture
ObservableFuture<T>(Future<T> future, {ReactiveContext? context, String? name})Create a new observable future that tracks the state of the provided future.
ObservableFuture.value
ObservableFuture<T>.value(T value, {ReactiveContext? context, String? name})Create a new future that is completed with a value.
[status] is immediately [FutureStatus.fulfilled].
ObservableFuture.error
ObservableFuture<T>.error(Object error, {ReactiveContext? context, String? name})Create a new future that is completed with an error.
[status] is immediately [FutureStatus.rejected].
name
String nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
status
FutureStatus statusUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
value
T? valueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
error
dynamic errorUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
result
dynamic resultUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String get nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
status
FutureStatus get statusObservable status of this.
value
T? get valueValue if this completed with a value.
Null otherwise.
error
dynamic get errorError value if this completed with an error
Null otherwise.
result
dynamic get resultError or value of this.
Null if this hasn't yet completed.
match
R? match<R>({R Function(T)? fulfilled, R Function(dynamic)? rejected, R Function()? pending})Maps the current state of this.
Returns null if a handler for the current state is not provided.
replace
ObservableFuture<T> replace(Future<T> nextFuture)Returns a new future that starts with the [status] and [result] of this.
The [status] and [result] changes when the provided future completes. Useful when you don't want to clear the result of the previous operation while executing the new operation.
asStream
ObservableStream<T> asStream()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
catchError
ObservableFuture<T> catchError(Function onError, {bool Function(Object)? test})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
then
ObservableFuture<R> then<R>(FutureOr<R> Function(T) onValue, {Function? onError})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
timeout
ObservableFuture<T> timeout(Duration timeLimit, {FutureOr<T> Function()? onTimeout})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
whenComplete
ObservableFuture<T> whenComplete(FutureOr<dynamic> Function() action)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableFutureExtension
Import: package:mobx/mobx.dart
extension ObservableFutureExtension<T> on Future<T>Turn the Future into an ObservableFuture.
asObservable
ObservableFuture<T> asObservable({ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableList
Import: package:mobx/mobx.dart
class ObservableList<T> with ListBase<T> implements Listenable<ListChange<T>>The ObservableList tracks the various read-methods (eg: [List.first], [List.last]) and write-methods (eg: [List.add], [List.insert]) making it easier to use it inside reactions.
As the name suggests, this is the Observable-counterpart to the standard Dart List<T>.
final list = ObservableList<int>.of([1]);
autorun((_) {
print(list.first);
}) // prints 1
list[0] = 100; // autorun prints 100ObservableList
ObservableList<T>({ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableList.of
ObservableList<T>.of(Iterable<T> elements, {ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
nonObservableInner
List<T> nonObservableInnerUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
length
int lengthUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
iterator
Iterator<T> iteratorUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
single
T singleUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
first
T firstUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
nonObservableInner
List<T> get nonObservableInnerUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String get nameThe name used to identify for debugging purposes
length
int get lengthUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
iterator
Iterator<T> get iteratorUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
single
T get singleUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
length
set length(int value)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
first
set first(T value)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
+
List<T> +(List<T> other)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
[]
T [](int index)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
[]=
void []=(int index, T value)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
add
void add(T element)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
addAll
void addAll(Iterable<T> iterable)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
lastIndexWhere
int lastIndexWhere(bool Function(T) test, [int? start])Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
lastWhere
T lastWhere(bool Function(T) test, {T Function()? orElse})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
sublist
List<T> sublist(int start, [int? end])Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
asMap
Map<int, T> asMap()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
cast
List<R> cast<R>()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
toList
List<T> toList({bool growable = true})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
clear
void clear()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
fillRange
void fillRange(int start, int end, [T? fill])Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
insert
void insert(int index, T element)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
insertAll
void insertAll(int index, Iterable<T> iterable)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
remove
bool remove(Object? element)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
removeAt
T removeAt(int index)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
removeLast
T removeLast()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
removeRange
void removeRange(int start, int end)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
removeWhere
void removeWhere(bool Function(T) test)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
replaceRange
void replaceRange(int start, int end, Iterable<T> newContents)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
retainWhere
void retainWhere(bool Function(T) test)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
setAll
void setAll(int index, Iterable<T> iterable)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
setRange
void setRange(int start, int end, Iterable<T> iterable, [int skipCount = 0])Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
shuffle
void shuffle([Random? random])Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
sort
void sort([int Function(T, T)? compare])Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
observe
void Function() observe(void Function(ListChange<T>) listener, {bool fireImmediately = false})Attach a [listener] to the changes happening in the list.
You can choose to receive the change notification immediately (with [fireImmediately]) or on the first change
ObservableListExtension
Import: package:mobx/mobx.dart
extension ObservableListExtension<T> on List<T>Turn the List into an ObservableList.
asObservable
ObservableList<T> asObservable({ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableMap
Import: package:mobx/mobx.dart
class ObservableMap<K, V> with MapBase<K, V> implements Listenable<MapChange<K, V>>The ObservableMap tracks the various read-methods (eg: [Map.length], [Map.isEmpty]) and write-methods (eg: [Map.[]=], [Map.clear]) making it easier to use it inside reactions.
As the name suggests, this is the Observable-counterpart to the standard Dart Map<K,V>.
final map = ObservableMap<String, int>.of({'first': 1});
autorun((_) {
print(map['first']);
}) // prints 1
map['first'] = 100; // autorun prints 100ObservableMap
ObservableMap<K, V>({ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableMap.of
ObservableMap<K, V>.of(Map<K, V> other, {ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableMap.linkedHashMapFrom
ObservableMap<K, V>.linkedHashMapFrom(Map<K, V> other, {ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableMap.splayTreeMapFrom
ObservableMap<K, V>.splayTreeMapFrom(Map<K, V> other, {int Function(K, K)? compare, bool Function(dynamic)? isValidKey, ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
nonObservableInner
Map<K, V> nonObservableInnerUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
keys
Iterable<K> keysUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
length
int lengthUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isNotEmpty
bool isNotEmptyUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isEmpty
bool isEmptyUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
nonObservableInner
Map<K, V> get nonObservableInnerUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String get nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
keys
Iterable<K> get keysUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
length
int get lengthUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isNotEmpty
bool get isNotEmptyUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isEmpty
bool get isEmptyUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
[]
V? [](Object? key)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
[]=
void []=(K key, V value)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
addAll
void addAll(Map<K, V> other)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
addEntries
void addEntries(Iterable<MapEntry<K, V>> newEntries)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
updateAll
void updateAll(V Function(K, V) update)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
removeWhere
void removeWhere(bool Function(K, V) test)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
clear
void clear()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
cast
Map<RK, RV> cast<RK, RV>()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
remove
V? remove(Object? key)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
containsKey
bool containsKey(Object? key)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
observe
void Function() observe(void Function(MapChange<K, V>) listener, {bool fireImmediately = false})Used to attach a listener for getting notified on changes happening to the map
You can also choose to receive the notifications immediately (with [fireImmediately])
ObservableMapExtension
Import: package:mobx/mobx.dart
extension ObservableMapExtension<K, V> on Map<K, V>Turn the Map into an ObservableMap.
asObservable
ObservableMap<K, V> asObservable({ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableSet
Import: package:mobx/mobx.dart
class ObservableSet<T> with SetBase<T> implements Listenable<SetChange<T>>ObservableSet provides a reactive set that notifies changes when a member is added or removed.
final set = ObservableSet.of([1, 2, 3]);
const disposer = autorun((_){
print(set);
});
set.add(4); // prints {1, 2, 3, 4}ObservableSet
ObservableSet<T>({ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableSet.of
ObservableSet<T>.of(Iterable<T> other, {ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableSet.splayTreeSetFrom
ObservableSet<T>.splayTreeSetFrom(Iterable<T> other, {int Function(T, T)? compare, bool Function(dynamic)? isValidKey, ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
nonObservableInner
Set<T> nonObservableInnerUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
iterator
Iterator<T> iteratorUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
length
int lengthUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
nonObservableInner
Set<T> get nonObservableInnerUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String get nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
iterator
Iterator<T> get iteratorUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
length
int get lengthUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
add
bool add(T value)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
addAll
void addAll(Iterable<T> elements)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
removeAll
void removeAll(Iterable<Object?> elements)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
retainAll
void retainAll(Iterable<Object?> elements)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
removeWhere
void removeWhere(bool Function(T) test)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
retainWhere
void retainWhere(bool Function(T) test)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
contains
bool contains(Object? element)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
lookup
T? lookup(Object? element)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
remove
bool remove(Object? value)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
clear
void clear()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
cast
Set<R> cast<R>()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
toSet
Set<T> toSet()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
observe
void Function() observe(void Function(SetChange<T>) listener, {bool fireImmediately = false})Attaches a listener to changes happening in the [ObservableSet]. You have the option to be notified immediately ([fireImmediately]) or wait for until the first change.
ObservableSetExtension
Import: package:mobx/mobx.dart
extension ObservableSetExtension<T> on Set<T>Turn the Set into an ObservableSet.
asObservable
ObservableSet<T> asObservable({ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableStream
Import: package:mobx/mobx.dart
class ObservableStream<T> implements Stream<T>, ObservableValue<T?>Stream that tracks the emitted values of the provided stream and makes them available as a MobX observable value.
The latest events emitted by the stream are captured an made available as MobX observable values via properties such as [data], [value], [error], [hasError] and [status].
If the source stream is a single-subscription stream, this stream will also be single-subscription. Either calling [listen] or observing [value], etc. in a reaction will start the stream. Both can be done at the same time.
If the observation ends, and a subscription was never created via [listen], the stream will be paused. If a subscription (created via [listen]) is cancelled, the stream ends, and [value] etc. can no longer be observed inside a reaction.
If the source stream is a broadcast stream, this stream will also be a broadcast stream. This means the observable stream can be listened to multiple times.
ObservableStream
ObservableStream<T>(Stream<T> stream, {T? initialValue, bool cancelOnError = false, ReactiveContext? context, String? name, bool Function(dynamic, dynamic)? equals})Create a stream that tracks the emitted values of the provided stream and makes them available as a MobX observable value.
If the source stream is a single-subscription stream, this stream will also be single-subscription. If the source stream is a broadcast stream, this stream will also be a broadcast stream.
If initialValue is provided, [value] will use it as the initial value while waiting for the first item to be emitted from the source stream. If the stream is a single-subscription stream, initialValue will also be the first value emitted to the subscription created by [listen].
If cancelOnError is true, the stream will be cancelled when an error event is emitted by the source stream. The observable status becomes [StreamStatus.done] and downstream listeners receive the error followed by done, unless their own subscription cancels on error. The default value is false.
It is possible to override equality comparison of new values with [equals].
name
String nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
data
dynamic dataUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
value
T? valueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
error
dynamic errorUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
hasError
bool hasErrorUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
status
StreamStatus statusUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
first
ObservableFuture<T> firstUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isBroadcast
bool isBroadcastUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isEmpty
ObservableFuture<bool> isEmptyUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
last
ObservableFuture<T> lastUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
length
ObservableFuture<int> lengthUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
single
ObservableFuture<T> singleUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String get nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
data
dynamic get dataUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
value
T? get valueCurrent value or null if waiting and no initialValue, or null if data is an error.
error
dynamic get errorCurrent error or null if not failed.
hasError
bool get hasErrorCurrent data is an error.
status
StreamStatus get statusCurrent stream status.
first
ObservableFuture<T> get firstUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isBroadcast
bool get isBroadcastUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isEmpty
ObservableFuture<bool> get isEmptyUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
last
ObservableFuture<T> get lastUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
length
ObservableFuture<int> get lengthUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
single
ObservableFuture<T> get singleUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
match
R? match<R>({R Function()? waiting, R Function(T)? active, R Function(dynamic)? error, R Function(T?, dynamic)? done})Maps the current status and value or error into a value.
Returns null if a callback is not provided for the active status. If [done] is null, [active] and [error] are used instead.
configure
ObservableStream<T> configure({T? initialValue, bool cancelOnError = false})Create a new stream with the provided initialValue and cancelOnError.
close
Future<void> close()Close the observable stream, and stop any future updates to observable properties or any stream subscribers.
Most of the time, this method doesn't need to be called. ObservableStream can clean-up automatically. This is always true if the original stream is a broadcast stream.
However, if the original stream is a single-subscription stream and you previously observed the stream's properties ([data], [value], [error], [hasError], [status], etc.) but then stopped the observation (thereby pausing the stream), then this method can be used to ensure the original paused stream closes correctly.
Note that if you [listen] to this observable stream, the observable stream will be closed automatically when you cancel the subscription.
any
ObservableFuture<bool> any(bool Function(T) test)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
asBroadcastStream
ObservableStream<T> asBroadcastStream({void Function(StreamSubscription<T>)? onListen, void Function(StreamSubscription<T>)? onCancel})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
asyncExpand
ObservableStream<E> asyncExpand<E>(Stream<E>? Function(T) convert)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
asyncMap
ObservableStream<E> asyncMap<E>(FutureOr<E> Function(T) convert)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
cast
ObservableStream<R> cast<R>()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
contains
ObservableFuture<bool> contains(Object? needle)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
distinct
ObservableStream<T> distinct([bool Function(T, T)? equals])Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
drain
ObservableFuture<E> drain<E>([E? futureValue])Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
elementAt
ObservableFuture<T> elementAt(int index)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
every
ObservableFuture<bool> every(bool Function(T) test)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
expand
ObservableStream<S> expand<S>(Iterable<S> Function(T) convert)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
firstWhere
ObservableFuture<T> firstWhere(bool Function(T) test, {T Function()? orElse})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
fold
ObservableFuture<S> fold<S>(S initialValue, S Function(S, T) combine)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
forEach
ObservableFuture<dynamic> forEach(void Function(T) action)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
handleError
ObservableStream<T> handleError(Function onError, {bool Function(dynamic)? test})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
join
ObservableFuture<String> join([String separator = ''])Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
lastWhere
ObservableFuture<T> lastWhere(bool Function(T) test, {T Function()? orElse})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
listen
StreamSubscription<T> listen(void Function(T)? onData, {Function? onError, void Function()? onDone, bool? cancelOnError})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
map
ObservableStream<S> map<S>(S Function(T) convert)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
pipe
ObservableFuture<dynamic> pipe(StreamConsumer<T> streamConsumer)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
reduce
ObservableFuture<T> reduce(T Function(T, T) combine)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
singleWhere
ObservableFuture<T> singleWhere(bool Function(T) test, {T Function()? orElse})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
skip
ObservableStream<T> skip(int count)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
skipWhile
ObservableStream<T> skipWhile(bool Function(T) test)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
take
ObservableStream<T> take(int count)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
takeWhile
ObservableStream<T> takeWhile(bool Function(T) test)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
timeout
ObservableStream<T> timeout(Duration timeLimit, {void Function(EventSink<T>)? onTimeout})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
toList
ObservableFuture<List<T>> toList()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
toSet
ObservableFuture<Set<T>> toSet()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
transform
ObservableStream<S> transform<S>(StreamTransformer<T, S> streamTransformer)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
where
ObservableStream<T> where(bool Function(T) test)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableStreamExtension
Import: package:mobx/mobx.dart
extension ObservableStreamExtension<T> on Stream<T>Turn the Stream into an ObservableStream.
asObservable
ObservableStream<T> asObservable({T? initialValue, bool cancelOnError = false, ReactiveContext? context, String? name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableValue
Import: package:mobx/mobx.dart
abstract class ObservableValue<T>See the API families guide for usage and ownership. This declaration is part of the public export surface.
ObservableValue
ObservableValue<T>()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
value
T valueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
value
T get valueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObservableValueSpyEvent
Import: package:mobx/mobx.dart
class ObservableValueSpyEvent extends SpyEventUsed for reporting value changes on an Observable
ObservableValueSpyEvent
ObservableValueSpyEvent(dynamic object, {dynamic newValue, dynamic oldValue, required String name, bool isEnd = false})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
newValue
dynamic newValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
oldValue
dynamic oldValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
newValue
dynamic get newValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
oldValue
dynamic get oldValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
toString
String toString()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
OperationType
Import: package:mobx/mobx.dart
enum OperationTypeSee the API families guide for usage and ownership. This declaration is part of the public export surface.
OperationType
OperationType()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
add
OperationType addUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
update
OperationType updateUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
remove
OperationType removeUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
values
List<OperationType> valuesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
add
OperationType get addUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
update
OperationType get updateUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
remove
OperationType get removeUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
values
List<OperationType> get valuesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
Reaction
Import: package:mobx/mobx.dart
abstract class Reaction implements DerivationSee the API families guide for usage and ownership. This declaration is part of the public export surface.
Reaction
Reaction()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isDisposed
bool isDisposedUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
debugCreationStack
StackTrace? debugCreationStackUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isDisposed
bool get isDisposedUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
debugCreationStack
StackTrace? get debugCreationStackUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
dispose
void dispose()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ReactionDisposedSpyEvent
Import: package:mobx/mobx.dart
class ReactionDisposedSpyEvent extends SpyEventSee the API families guide for usage and ownership. This declaration is part of the public export surface.
ReactionDisposedSpyEvent
ReactionDisposedSpyEvent({required String name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ReactionDisposer
Import: package:mobx/mobx.dart
class ReactionDisposerA callable class that is used to dispose a [reaction], [autorun] or [when]
var dispose = autorun((){
// ...
});
dispose(); // dispose the autorun()In the above code, dispose is of type ReactionDisposer.
ReactionDisposer
ReactionDisposer(Reaction reaction)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
reaction
Reaction reactionUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
reaction
Reaction get reactionUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
call
void call()Invoking it will dispose the underlying [reaction]
ReactionErrorHandler
Import: package:mobx/mobx.dart
typedef ReactionErrorHandler = void Function(Object, Reaction)See the API families guide for usage and ownership. This declaration is part of the public export surface.
ReactionErrorSpyEvent
Import: package:mobx/mobx.dart
class ReactionErrorSpyEvent extends SpyEventSee the API families guide for usage and ownership. This declaration is part of the public export surface.
ReactionErrorSpyEvent
ReactionErrorSpyEvent(Object error, {required String name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
error
Object errorUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
error
Object get errorUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
toString
String toString()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ReactionSpyEvent
Import: package:mobx/mobx.dart
class ReactionSpyEvent extends SpyEventSee the API families guide for usage and ownership. This declaration is part of the public export surface.
ReactionSpyEvent
ReactionSpyEvent({required String name})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ReactiveConfig
Import: package:mobx/mobx.dart
class ReactiveConfigConfiguration used by [ReactiveContext]
ReactiveConfig
ReactiveConfig({bool disableErrorBoundaries = false, ReactiveWritePolicy writePolicy = ReactiveWritePolicy.observed, ReactiveReadPolicy readPolicy = ReactiveReadPolicy.never, int maxIterations = 100, bool isSpyEnabled = false})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
main
ReactiveConfig mainThe main or default configuration used by [ReactiveContext]
disableErrorBoundaries
bool disableErrorBoundariesWhether MobX should throw exceptions instead of catching them and store as [Derivation.errorValue].
writePolicy
ReactiveWritePolicy writePolicyEnforce mutation of observables inside an action
readPolicy
ReactiveReadPolicy readPolicyEnforce the use of reactions for reading observables
maxIterations
int maxIterationsMax number of iterations before bailing out for a cyclic reaction
isSpyEnabled
bool isSpyEnabledUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
main
ReactiveConfig get mainUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
disableErrorBoundaries
bool get disableErrorBoundariesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
writePolicy
ReactiveWritePolicy get writePolicyUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
readPolicy
ReactiveReadPolicy get readPolicyUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
maxIterations
int get maxIterationsUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isSpyEnabled
bool get isSpyEnabledUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
clone
ReactiveConfig clone({bool? disableErrorBoundaries, ReactiveWritePolicy? writePolicy, ReactiveReadPolicy? readPolicy, int? maxIterations, bool? isSpyEnabled})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ReactiveContext
Import: package:mobx/mobx.dart
class ReactiveContextSee the API families guide for usage and ownership. This declaration is part of the public export surface.
ReactiveContext
ReactiveContext({ReactiveConfig? config})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
config
ReactiveConfig configUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
nextId
int nextIdUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isWithinBatch
bool isWithinBatchUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isSpyEnabled
bool isSpyEnabledUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
config
ReactiveConfig get configUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
nextId
int get nextIdUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isWithinBatch
bool get isWithinBatchUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isSpyEnabled
bool get isSpyEnabledUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
config
set config(ReactiveConfig newValue)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
nameFor
String nameFor(String prefix)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
spy
void Function() spy(void Function(SpyEvent) listener)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
spyReport
void spyReport(SpyEvent event)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
startBatch
void startBatch()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
endBatch
void endBatch()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
enforceReadPolicy
void enforceReadPolicy(Atom atom)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
enforceWritePolicy
void enforceWritePolicy(Atom atom)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
trackDerivation
T? trackDerivation<T>(Derivation d, T Function() fn)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
reportObserved
void reportObserved(Atom atom)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
addPendingReaction
void addPendingReaction(Reaction reaction)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
runReactions
void runReactions()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
propagateChanged
void propagateChanged(Atom atom)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
clearObservables
void clearObservables(Derivation derivation)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isComputingDerivation
bool isComputingDerivation()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
startUntracked
Derivation? startUntracked()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
endUntracked
void endUntracked(Derivation? prevDerivation)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
untracked
T untracked<T>(T Function() fn)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
onReactionError
void Function() onReactionError(void Function(Object, Reaction) handler)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
startAllowStateChanges
bool startAllowStateChanges({bool allow = true})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
endAllowStateChanges
void endAllowStateChanges({bool allow = true})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
pushComputation
void pushComputation()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
popComputation
void popComputation()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ReactiveReadPolicy
Import: package:mobx/mobx.dart
enum ReactiveReadPolicyDefines the behavior for observables read outside actions and reactions
always: If observables are read outside actions/reactions, throw an Exception never: Allow unrestricted reading of observables everywhere. This is the default.
ReactiveReadPolicy
ReactiveReadPolicy()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
always
ReactiveReadPolicy alwaysUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
never
ReactiveReadPolicy neverUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
values
List<ReactiveReadPolicy> valuesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
always
ReactiveReadPolicy get alwaysUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
never
ReactiveReadPolicy get neverUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
values
List<ReactiveReadPolicy> get valuesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ReactiveWritePolicy
Import: package:mobx/mobx.dart
enum ReactiveWritePolicyDefines the behavior for observables mutated outside actions
observed: If there are observers for the mutated observable, then throw. Else allow mutation outside an action. always: Always throw if an observable is mutated outside an action never: Allow mutating observables outside actions
ReactiveWritePolicy
ReactiveWritePolicy()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
observed
ReactiveWritePolicy observedUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
always
ReactiveWritePolicy alwaysUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
never
ReactiveWritePolicy neverUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
values
List<ReactiveWritePolicy> valuesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
observed
ReactiveWritePolicy get observedUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
always
ReactiveWritePolicy get alwaysUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
never
ReactiveWritePolicy get neverUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
values
List<ReactiveWritePolicy> get valuesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
SetChange
Import: package:mobx/mobx.dart
class SetChange<T>Capture the change related information for an [ ObservableSet]. This is used as the notification instance.
SetChange
SetChange<T>({required ObservableSet<T> object, required OperationType type, required T? value})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
object
ObservableSet<T> objectUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
type
OperationType typeUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
value
T? valueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
object
ObservableSet<T> get objectUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
type
OperationType get typeUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
value
T? get valueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
SetChangeListener
Import: package:mobx/mobx.dart
typedef SetChangeListener<in T> = void Function(SetChange<T>)See the API families guide for usage and ownership. This declaration is part of the public export surface.
SpyEvent
Import: package:mobx/mobx.dart
abstract class SpyEventSee the API families guide for usage and ownership. This declaration is part of the public export surface.
object
dynamic objectUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
type
String typeUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
duration
Duration? durationUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isStart
bool isStartUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isEnd
bool isEndUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
sentinel
String sentinelUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
object
dynamic get objectUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
name
String get nameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
type
String get typeUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
duration
Duration? get durationUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isStart
bool get isStartUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
isEnd
bool get isEndUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
sentinel
String get sentinelUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
toString
String toString()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
SpyListener
Import: package:mobx/mobx.dart
typedef SpyListener = void Function(SpyEvent)See the API families guide for usage and ownership. This declaration is part of the public export surface.
Store
Import: package:mobx/mobx.dart
mixin Store on ObjectThe Store mixin is primarily meant for code-generation and used as part of the mobx_codegen package.
A class using this mixin is considered a MobX store and mobx_codegen weaves the code needed to simplify the usage of MobX. It will detect annotations like @observables, @computed and @action and generate the code needed to support these behaviors.
context
ReactiveContext contextUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
context
ReactiveContext get contextOverride this method to use a custom context.
StoreConfig
Import: package:mobx/mobx.dart
class StoreConfigSee the API families guide for usage and ownership. This declaration is part of the public export surface.
StoreConfig
StoreConfig({bool hasToString = true})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
hasToString
bool hasToStringUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
hasToString
bool get hasToStringUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
StreamStatus
Import: package:mobx/mobx.dart
enum StreamStatusSee the API families guide for usage and ownership. This declaration is part of the public export surface.
StreamStatus
StreamStatus()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
waiting
StreamStatus waitingUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
active
StreamStatus activeUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
done
StreamStatus doneUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
values
List<StreamStatus> valuesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
waiting
StreamStatus get waitingUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
active
StreamStatus get activeUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
done
StreamStatus get doneUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
values
List<StreamStatus> get valuesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
StringExtension
Import: package:mobx/mobx.dart
extension StringExtension on StringSee the API families guide for usage and ownership. This declaration is part of the public export surface.
obs
Observable<String> obs({ReactiveContext? context, String? name})turns a String into Observable
WillChangeNotification
Import: package:mobx/mobx.dart
class WillChangeNotification<T>See the API families guide for usage and ownership. This declaration is part of the public export surface.
WillChangeNotification
WillChangeNotification<T>({OperationType? type, T? newValue, dynamic object})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
type
OperationType? typeOne of add | update | delete
newValue
T? newValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
object
dynamic objectUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
unchanged
WillChangeNotification<dynamic> unchangedUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
type
OperationType? get typeUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
newValue
T? get newValueUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
object
dynamic get objectUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
unchanged
WillChangeNotification<dynamic> get unchangedUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
newValue
set newValue(T? value)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
unchanged
set unchanged(WillChangeNotification<dynamic> value)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
action
Import: package:mobx/mobx.dart
MakeAction get actionSee the API families guide for usage and ownership. This declaration is part of the public export surface.
alwaysNotify
Import: package:mobx/mobx.dart
MakeObservable get alwaysNotifySee the API families guide for usage and ownership. This declaration is part of the public export surface.
asyncWhen
Import: package:mobx/mobx.dart
Future<void> asyncWhen(bool Function(Reaction) predicate, {String? name, int? timeout, ReactiveContext? context})A variant of [when()] which returns a Future. The Future completes when the [predicate()] turns true. Note that there is no effect function here. Typically you would await on the Future and execute the effect after that.
await asyncWhen((_) => x.value > 10);
// ... execute the effect ...autorun
Import: package:mobx/mobx.dart
ReactionDisposer autorun(dynamic Function(Reaction) fn, {String? name, int? delay, ReactiveContext? context, Timer Function(void Function())? scheduler, void Function(Object, Reaction)? onError})Executes the specified [fn], whenever the dependent observables change. It returns a disposer that can be used to dispose the autorun.
Optional configuration:
- [name]: debug name for this reaction
- [delay]: Number of milliseconds that can be used to throttle the effect function. If zero (default), no throttling happens.
- [context]: the [ReactiveContext] to use. By default the [mainContext] is used.
- [scheduler]: Set a custom scheduler to determine how re-running the autorun function should be scheduled. It takes a function that should be invoked at some point in the future.
- [onError]: By default, any exception thrown inside an reaction will be logged, but not further thrown. This is to make sure that an exception in one reaction does not prevent the scheduled execution of other, possibly unrelated reactions. This also allows reactions to recover from exceptions. Throwing an exception does not break the tracking done by MobX, so subsequent runs of the reaction might complete normally again if the cause for the exception is removed. This option allows overriding that behavior. It is possible to set a global error handler or to disable catching errors completely using [ReactiveConfig].
var x = Observable(10);
var y = Observable(20);
var total = Observable(0);
var dispose = autorun((_){
print('x = ${x}, y = ${y}, total = ${total}');
});
x.value = 20; // will cause autorun() to re-trigger.
dispose(); // This disposes the autorun() and will not be triggered again
x.value = 30; // Will not cause autorun() to re-trigger as it's disposed.computed
Import: package:mobx/mobx.dart
ComputedMethod get computedSee the API families guide for usage and ownership. This declaration is part of the public export surface.
createContext
Import: package:mobx/mobx.dart
ReactiveContext createContext({ReactiveConfig? config})Create a new context for running actions and reactions.
You can use this to run a reactivity system in parallel to the [mainContext]. All actions, reactions will be run within this context. Make sure to pass this context in calls to autorun, reaction, when, action, observable, etc.
Most of the time you should be fine with the [mainContext]
mainContext
Import: package:mobx/mobx.dart
ReactiveContext get mainContextSee the API families guide for usage and ownership. This declaration is part of the public export surface.
observable
Import: package:mobx/mobx.dart
MakeObservable get observableSee the API families guide for usage and ownership. This declaration is part of the public export surface.
observableAlwaysNotEqual
Import: package:mobx/mobx.dart
bool observableAlwaysNotEqual(dynamic _, dynamic _)See the API families guide for usage and ownership. This declaration is part of the public export surface.
reaction
Import: package:mobx/mobx.dart
ReactionDisposer reaction<T>(T Function(Reaction) fn, void Function(T) effect, {String? name, int? delay, bool? fireImmediately, bool Function(T?, T?)? equals, ReactiveContext? context, Timer Function(void Function())? scheduler, void Function(Object, Reaction)? onError})Executes the [fn] function and tracks the observables used in it. Returns a function to dispose the reaction.
Optional configuration:
- [name]: debug name for this reaction
- [delay]: Number of milliseconds that can be used to throttle the effect function. If zero (default), no throttling happens.
- [context]: the [ReactiveContext] to use. By default the [mainContext] is used.
- [scheduler]: Set a custom scheduler to determine how re-running the autorun function should be scheduled. It takes a function that should be invoked at some point in the future.
- [onError]: By default, any exception thrown inside an reaction will be logged, but not further thrown. This is to make sure that an exception in one reaction does not prevent the scheduled execution of other, possibly unrelated reactions. This also allows reactions to recover from exceptions. Throwing an exception does not break the tracking done by MobX, so subsequent runs of the reaction might complete normally again if the cause for the exception is removed. This option allows overriding that behavior. It is possible to set a global error handler or to disable catching errors completely using [ReactiveConfig].
The [fn] is supposed to return a value of type T. When it changes, the [effect] function is executed.
Note: Only the [fn] function is tracked and not the [effect].
You can also pass in an optional [name], a throttling [delay] in milliseconds. Use [fireImmediately] if you want to invoke the effect immediately without waiting for the [fn] to change its value. It is possible to define a custom [equals] function to override the default comparison for the value returned by [fn], to have fined grained control over when the reactions should run. By default, the [mainContext] is used, but you can also pass in a custom [context]. You can also pass in an optional [onError] handler for errors thrown during the [fn] execution. You can also pass in an optional [scheduler] to schedule the [effect] execution.
readonly
Import: package:mobx/mobx.dart
MakeObservable get readonlySee the API families guide for usage and ownership. This declaration is part of the public export surface.
runInAction
Import: package:mobx/mobx.dart
T runInAction<T>(T Function() fn, {String? name, ReactiveContext? context})Executes the mutation function [fn] within an Action. This ensures that all change notifications are fired only at the end of the Action block. Note that actions can be nested, in which case the notifications go out when the outermost Action completes.
Giving a [name] makes it easier to identify this action during debugging. You can also run this in a custom [context]. By default the mainContext will be used.
transaction
Import: package:mobx/mobx.dart
T transaction<T>(T Function() fn, {ReactiveContext? context})During a transaction, no derivations ([Reaction] or [Computed]) will be run and will be deferred until the end of the transaction (batch). Transactions can be nested, in which case, no derivation will be run until the top-most batch completes
untracked
Import: package:mobx/mobx.dart
T untracked<T>(T Function() fn, {ReactiveContext? context})Untracked ensures there is no tracking derivation while the given action runs. This is useful in cases where no observers should be linked to a running (tracking) derivation.
version
Import: package:mobx/mobx.dart
String get versionSee the API families guide for usage and ownership. This declaration is part of the public export surface.
when
Import: package:mobx/mobx.dart
ReactionDisposer when(bool Function(Reaction) predicate, void Function() effect, {String? name, ReactiveContext? context, int? timeout, void Function(Object, Reaction)? onError})A one-time reaction that auto-disposes when the [predicate] becomes true. It also executes the [effect] when the predicate turns true.
You can read it as: "when [predicate()] turns true, the [effect()] is executed."
Returns a function to dispose pre-maturely.