Actual Type: Method
Note: Stripped to generate better documentation.
Builds the FutureMachine and returns its FuturesAPI.
No methods can be created or entities registered after this is called.
Actual Type: Method
Note: Stripped to generate better documentation.
Creates a Method.
Can only be called before build() is called
A unique identifier, only used for the FutureMachine to serialize and deserialize the method to the database.
Must be registered with the same name for each session. When a Method is deserialized and it hasn't been created for this session, the Method it is bound to will throw an Exception when called.
The implementation of the Method.
Arguments can be of any type, but the return type must be a Serializable.
A Method which is a thin wrapper of impl.
Actual Type: Method
Note: Stripped to generate better documentation.
Registers an Entity.
Can only be called before build() is called
A unique identifier, only used for the FutureMachine to serialize and deserialize the entity to the database.
Must be registered with the same name for each session. When a Entity is deserialized and it hasn't been created for this session, the Method it is bound to will throw an Exception when called.
A class that extends Entity.
Once registered, it's a Serializable.
A callback that returns the implementation of entity's
constructor. The constructor must build a State using the
StateBuilder and must return an instance of the entity
constructed with that State.
Returns a Method, the constructor of entity.
const { methods } = createFutureMachine(db);
type stateType = {
name: string;
count: number | undefined;
};
class MyClass extends Entity<stateType> {
getName() {
return this.get("name");
}
setCount(value: number | undefined) {
this.set("count", value);
}
getCount() {
return this.get("count");
}
}
const createMyClass = methods.registerEntity(
'MyClass',
MyClass,
(stateBuilder: StateBuilder) => (name: string) => {
return new MyClass(
stateBuilder.build({
name,
count: undefined,
})
);
}
);
The API for building the FutureMachine.
All Methods must be created and Entitys must be registered at the beginning of every session before build() is called.