-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
todo-mvc: Use declarative DSL #56
Conversation
Store actions are never retrieved from the app factory so they don't have to be registered. Do configure them though.
Unlike other UI actions, the filter action is only referenced from the route. It does not need to be registered, but it must still be configured.
The router dispatches for the initial URL, but dispatches won't work until the app has started.
Declare the routes in a separate module to reduce clutter in the main module. It also helps make it clearer that the router is only started once the app is ready. Pass the app instance to routes via the dispatch context. This allows the routes to resolve the filter action before creating the filter route. Create a single route for all three filters, using parameter validation. The filter action must now be registered with the app and no longer has to be configured separately.
Ensure the TodoFooter widget resolves the clearCompleted action via the registry. Ensure the TodoItem widget resolves the actions via the registry.
This utilizes the new createWidget support in app and avoids having to register the item with the app.
Register the store declaratively, then bind actions once the app is ready. Widget actions can now be resolved via the app, so they need to be registered rather than configured. Quick refactor so the widget actions can resolve their store. Todo actions must now be configured after the app is started so they can resolve the todo store.
Refactor UI actions to resolve store actions upon configuration. Rename widget actions to avoid name clashes.
Better use of destructuring, ensure clear promise chains.
Use the types in store and widget actions.
Only register actions that are used declaratively. Since actions are code it's easier to refer to them directly from other actions / widgets. Now that stores live in their own module they're also easy to refer to, without going via the app.
Better typing of do() arguments. Return promises. Whitespace.
ca3222a
to
1d447e1
Compare
The corresponding |
export const toggleAll = createAction({ | ||
do({ checked: completed }: { checked: boolean }) { | ||
return todoStore.get() | ||
// <any> hammer since the store isn't typed to return an iterator (which it does). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove this hammer after updating to the latest dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it seems to return an IteratorShim
and I still need the hammer. @kitsonk ?
I may have gotten a bit carried away with this… apologies :)
todo-item
custom element is registered declaratively, though maybe it should be done inmain.ts