@@ -151,11 +151,11 @@ function Switch() {
151151}
152152
153153const machine = start (Switch );
154- machine .current ; // "Off"
154+ machine .value . state ; // "Off"
155155machine .next (" FLICK" );
156- machine .current ; // "On"
156+ machine .value . state ; // "On"
157157machine .next (" TOGGLE" );
158- machine .current ; // "Off"
158+ machine .value . state ; // "Off"
159159```
160160
161161### ` enter(action: () => undefined | unknown | Promise<unknown>) `
@@ -184,11 +184,11 @@ function Switch() {
184184
185185const machine = start (Switch );
186186machine .next (" FLICK" );
187- console .log (recordOn , machine .current ); // 1, "ON"
187+ console .log (onCount , machine .value . state ); // 1, "ON"
188188machine .next (" FLICK" );
189- console .log (recordOn , machine .current ); // 1, "OFF"
189+ console .log (onCount , machine .value . state ); // 1, "OFF"
190190machine .next (" FLICK" );
191- console .log (recordOn , machine .current ); // 2, "ON"
191+ console .log (onCount , machine .value . state ); // 2, "ON"
192192```
193193
194194### ` exit(action: () => undefined | unknown | Promise<unknown>) `
@@ -216,11 +216,11 @@ function Session() {
216216}
217217
218218const machine = start (Switch );
219- console .log (lastSessionEnded , machine .current ); // null, "SignedOut"
219+ console .log (lastSessionEnded , machine .value . state ); // null, "SignedOut"
220220machine .next (" AUTHENTICATE" );
221- console .log (lastSessionEnded , machine .current ); // null, "SignedIn"
221+ console .log (lastSessionEnded , machine .value . state ); // null, "SignedIn"
222222machine .next (" LOG_OFF" );
223- console .log (lastSessionEnded , machine .current ); // (current time), "SignedOut"
223+ console .log (lastSessionEnded , machine .value . state ); // (current time), "SignedOut"
224224```
225225
226226### ` cond(predicate: () => boolean, target: GeneratorFunction) `
@@ -251,11 +251,11 @@ function ButtonClickListener(button: HTMLButtonElement) {
251251const button = document .createElement (' button' );
252252const machine = start (ButtonClickListener .bind (null , button ));
253253
254- machine .current ; // "initial"
254+ machine .value ; // { state: "initial", change: 0 }
255255button .click ();
256- machine .current ; // "clicked"
256+ machine .value ; // { state: "clicked", change: 1 }
257257button .click ();
258- machine .current ; // "clicked"
258+ machine .value ; // { state: "initial", change: 1 }
259259```
260260
261261## Examples
@@ -299,19 +299,19 @@ function Loader() {
299299}
300300
301301const loader = start (Loader);
302- loader .current ; // "idle"
302+ loader .value ; // { state: "idle", change: 0 }
303303
304304loader .next (" FETCH" );
305- loader .current ; // "loading"
305+ loader .value ; // { state: "loading", change: 1, results: Promise }
306306
307- loader .results .then ((results ) => {
307+ loader .value . results .then ((results ) => {
308308 console .log (" Fetched" , results .fetchData ); // Use response of fetch()
309- loader .current ; // "success"
309+ loader .value . state ; // "success"
310310});
311311
312312/* Or with await: */
313- // const { fetchData } = await loader.results;
314- // loader.current ; // "success"
313+ // const { fetchData } = await loader.value. results;
314+ // loader.value.state ; // "success"
315315```
316316
317317### Passing parameters to a machine with closures
@@ -349,14 +349,14 @@ function SpecificLoader() {
349349
350350// Start our specific loader machine
351351const loader = start (SpecificLoader);
352- loader .current ; // "idle"
352+ loader .value ; // { state: "idle", change: 0 }
353353
354354loader .next (" FETCH" );
355- loader .current ; // "loading"
355+ loader .value ; // { state: "loading", change: 1, results: Promise }
356356
357- loader .results .then ((results ) => {
357+ loader .value . results .then ((results ) => {
358358 console .log (" Fetched" , results .fetchData ); // Use response of fetch()
359- loader .current ; // "success"
359+ loader .value . state ; // "success"
360360});
361361```
362362
@@ -380,9 +380,9 @@ function AbortListener(controller: AbortController) {
380380const aborter = new AbortController ();
381381const machine = start (AbortListener .bind (null , aborter ));
382382
383- machine .current ; // "initial"
383+ machine .value ; // { state: "initial", change: 0 }
384384aborter .abort ();
385- machine .current ; // "aborted"
385+ machine .value ; // { state: "aborted", change: 1 }
386386```
387387
388388----
0 commit comments