forked from LevelbossMike/ember-statecharts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
47 lines (47 loc) · 1.33 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import useMachine, {
ConfigurableMachineDefinition,
InterpreterUsable,
} from './usables/use-machine';
import { EventObject, StateSchema, StateValue, Typestate } from 'xstate';
declare function matchesState(state: StateValue, statechartPropertyName?: string): any;
/**
* No-op typecast function that turns what TypeScript believes to be a
* ConfigurableMachineDefinition function into a InterpreterUsable.
*
* ```js
* import { useMachine, interpreterFor } from 'ember-statecharts';
*
* class Foo extends EmberObject {
* @use statechart = useMachine(...) {
* // ...
* }
*
* someMethod() {
* this.statechart.send('WAT'); // TypeError
* interpreterFor(this.statechart).send('WAT'); // ok!
* }
* }
* ```
*
* @param configurableMachineDefinition The ConfigurableMachineDefinition used
* to initialize the `useMachine`-usable via `@use`
*
* Note that this is purely a typecast function.
*/
declare function interpreterFor<
TContext,
TStateSchema extends StateSchema,
TEvent extends EventObject,
TTypestate extends Typestate<TContext> = {
value: any;
context: TContext;
}
>(
configurableMachineDefinition: ConfigurableMachineDefinition<
TContext,
TStateSchema,
TEvent,
TTypestate
>
): InterpreterUsable<TContext, TStateSchema, TEvent>;
export { useMachine, matchesState, interpreterFor };