Skip to content

Commit 9201ea7

Browse files
committed
Rename ‘resolved’ to ‘results’
1 parent 0553b48 commit 9201ea7

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function Loader() {
3737
// This is the ‘loading’ state
3838
function* loading() {
3939
// This function will be called when this state is entered.
40-
// Its return value is available at `loader.resolved.fetchData`
40+
// Its return value is available at `loader.results.fetchData`
4141
yield entry(fetchData);
4242
// If the promise succeeds, we will transition to the `success` state
4343
// If the promise fails, we will transition to the `failure` state
@@ -62,14 +62,14 @@ loader.current; // "idle"
6262
loader.next("FETCH");
6363
loader.current; // "loading"
6464

65-
loader.resolved.then((result) => {
65+
loader.results.then((result) => {
6666
console.log("Fetched", result.fetchData);
6767
// Use response of fetch()
6868
loader.current; // "success"
6969
});
7070

7171
/* Or with await: */
72-
// const { fetchData } = await loader.resolved;
72+
// const { fetchData } = await loader.results;
7373
// loader.current; // "success"
7474
```
7575

@@ -113,7 +113,7 @@ loader.current; // "idle"
113113
loader.next("FETCH");
114114
loader.current; // "loading"
115115

116-
loader.resolved.then(([response]) => {
116+
loader.results.then(([response]) => {
117117
// Use response of fetch()
118118
loader.current; // "success"
119119
});

src/index.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe("Machine with entry and exit actions", () => {
6363
expect(loader.changeCount).toEqual(1);
6464
expect(finishedLoading).toHaveBeenCalledTimes(0);
6565

66-
await expect(loader.resolved).resolves.toEqual({ fetchData: 42 });
66+
await expect(loader.results).resolves.toEqual({ fetchData: 42 });
6767
await expect(Promise.resolve(transitionResult)).resolves.toEqual({ fetchData: 42 });
6868
expect(finishedLoading).toHaveBeenCalledTimes(1);
6969
expect(loader.changeCount).toEqual(2);
@@ -76,7 +76,7 @@ describe("Machine with entry and exit actions", () => {
7676
expect(loader.current).toEqual("success");
7777
expect(succeeded).toHaveBeenCalledTimes(1);
7878

79-
await loader.resolved;
79+
await loader.results;
8080
});
8181
});
8282

@@ -98,7 +98,7 @@ describe("Machine with entry and exit actions", () => {
9898
expect(loader.current).toEqual("loading");
9999
expect(loader.changeCount).toEqual(1);
100100

101-
await expect(loader.resolved).rejects.toEqual(new Error("Failed!"));
101+
await expect(loader.results).rejects.toEqual(new Error("Failed!"));
102102
await expect(Promise.resolve(transitionResult)).rejects.toEqual(
103103
new Error("Failed!")
104104
);
@@ -116,7 +116,7 @@ describe("Machine with entry and exit actions", () => {
116116
expect(fetch).toHaveBeenCalledTimes(2);
117117
expect(fetch).toHaveBeenLastCalledWith("https://example.org/");
118118

119-
await expect(loader.resolved).resolves.toEqual({ fetchData: 42 });
119+
await expect(loader.results).resolves.toEqual({ fetchData: 42 });
120120
expect(loader.changeCount).toEqual(4);
121121
expect(loader.current).toEqual("success");
122122
});

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function compound(...targets: Array<StateDefinition>): Compound {
7474
export interface MachineInstance extends Iterator<null | string | Record<string, string>, void, string> {
7575
changeCount: number;
7676
current: null | string | Record<string, string>;
77-
resolved: null | Promise<Array<any>>;
77+
results: null | Promise<Array<any>>;
7878
done: boolean;
7979
next(
8080
...args: [string]
@@ -204,7 +204,7 @@ class InternalInstance {
204204
}
205205
}
206206

207-
get value(): Promise<Array<any>> {
207+
get results(): Promise<Array<any>> {
208208
const build = async () => {
209209
const objects: Array<any> = [];
210210
for await (const object of this.valuePromises()) {
@@ -365,12 +365,12 @@ export function start(
365365
get current() {
366366
return instance.current !== null ? instance.current[rootName] : null;
367367
},
368-
get resolved() {
369-
return instance.value;
368+
get results() {
369+
return instance.results;
370370
},
371371
next(event: string) {
372372
instance.receive(event);
373-
const promise = instance.value;
373+
const promise = instance.results;
374374
return {
375375
value: instance.current !== null ? instance.current[rootName] : null,
376376
actions: instance.actions,

0 commit comments

Comments
 (0)