-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: enhanced thunk registry system (#44)
The current registry system for thunks works like this: - User calls `const thunks = createThunks()` - User creates **all** thunks `const go = thunks.create("go")` - User registers thunks `store.run(thunks.bootup)` However, there's a caveat with this implementation: all thunks must be created before `store.run` is called. Further, since thunks are created at the module-level, if the module that exports those thunks isn't loaded before `thunk.bootup` is called then those thunks are silently ignored. This change will make it so it doesn't matter when a thunk is created, we will "lazy load" it. We still require `store.run(thunks.bootup)` to be called -- because we need access to the store and won't have it when creating a thunk. We are also sending an error whenever a thunk is dispatched without it being registered which should help ensure thunks get properly registered. We also changed the name of `thunks.bootup` to `thunks.register` to make it more clear that this is a registry system.
- Loading branch information
Showing
6 changed files
with
100 additions
and
10 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export { assert } from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
export { | ||
afterAll, | ||
beforeAll, | ||
beforeEach, | ||
describe, | ||
it, | ||
|
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