Wait class

Immutable object to keep track of boolean flags that indicate if some process is in progress (the user is "waiting").

The flags and flag-references can be any immutable object. They must be immutable to make sure Wait is also immutable.

Use it in Redux store states, like this:

  • To add a flag: state.copy(wait: state.wait.add(flag: myFlag));
  • To remove a flag: state.copy(wait: state.wait.remove(flag: myFlag));
  • To clear all flags: state.copy(wait: state.wait.clear());

If can also use have a flag with a reference, like this:

  • To add a flag with reference: state.copy(wait: state.wait.add(flag: myFlag, ref:MyRef));
  • To remove a flag with reference: state.copy(wait: state.wait.remove(flag: myFlag, ref:MyRef));
  • To clear all references for a flag: state.copy(wait: state.wait.clear(flag: myFlag));

In the ViewModel, you can check the flags/references, like this:

  • To check if there is any waiting: state.wait.isWaitingAny
  • To check if is waiting a specific flag: state.wait.isWaiting(myFlag);
  • To check if is waiting a specific flag/reference: state.wait.isWaiting(myFlag, ref: myRef);
Annotations

Constructors

Wait()
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
isWaitingAny bool
Return true if there is any waiting (any flag).
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add({required Object? flag, Object? ref}) Wait
clear({Object? flag}) Wait
clearWhere(bool test(Object? flag, Set<Object?> refs)) → void
isWaiting(Object? flag, {Object? ref}) bool
Return true if is waiting for a specific flag. If ref is null, it returns true if it's waiting for any reference of the flag. If ref is not null, it returns true if it's waiting for that specific reference of the flag.
isWaitingForType<T>() bool
Return true if is waiting for ANY flag of the specific type.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
process(WaitOperation operation, {required Object? flag, Object? ref}) Wait
remove({required Object? flag, Object? ref}) Wait
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

ALL → const Object
Convenience flag that you can use when a null value means ALL. For example, suppose if you want until an async process schedules an appointment for specific time. However, if no time is selected, you want to schedule the whole day (all "times"). You can do: dispatch(WaitAction.add(appointment, ref: time ?? Wait.ALL));
empty → const Wait