-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Created ItemIsPending helper. * Created items stutuses resolver. * Created wait for store changes async helper. * Reexported all helpers. * Fixed naming and reexported helpers. * Fixed naming. * Fixed import. * Updated typescript. * Fixed ts errors. * Fixed naming. * Fixed Dispatcher class naming. * Fixed ts errors. * Fixed naming. * Fixed ts error.
- Loading branch information
1 parent
3294623
commit 8a1ffa7
Showing
11 changed files
with
105 additions
and
48 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { ItemIsPending } from "./helpers/item-is-pending"; | ||
export { ItemsStatusResolver } from "./helpers/items-status-resolver"; | ||
export { WaitForStoreChange } from "./helpers/wait-for-store-change"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ItemStatus } from "../abstractions"; | ||
|
||
export function ItemIsPending(status: ItemStatus): boolean { | ||
return (status <= ItemStatus.Pending); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ItemStatus } from "../abstractions"; | ||
|
||
export function ItemsStatusResolver(...statuses: ItemStatus[]): ItemStatus { | ||
let loadedCount: number = 0; | ||
let noDataCount: number = 0; | ||
let pendingCount: number = 0; | ||
|
||
for (let i = 0; i < statuses.length; i++) { | ||
const status = statuses[i]; | ||
switch (status) { | ||
case ItemStatus.Failed: | ||
return status; | ||
case ItemStatus.Loaded: | ||
loadedCount++; | ||
break; | ||
case ItemStatus.NoData: | ||
noDataCount++; | ||
break; | ||
case ItemStatus.Init: | ||
case ItemStatus.Pending: | ||
pendingCount++; | ||
break; | ||
} | ||
} | ||
|
||
if (pendingCount > 0) { | ||
return ItemStatus.Pending; | ||
} else if (loadedCount === 0 && noDataCount > 0) { | ||
return ItemStatus.NoData; | ||
} else { | ||
return ItemStatus.Loaded; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Store } from "flux/utils"; | ||
|
||
export async function WaitForStoreChange(store: Store<any>): Promise<void> { | ||
return new Promise<void>(resolve => { | ||
const listener = store.addListener(() => { | ||
listener.remove(); | ||
resolve(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters