Skip to content
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

Merged
merged 26 commits into from
Oct 5, 2016
Merged

todo-mvc: Use declarative DSL #56

merged 26 commits into from
Oct 5, 2016

Conversation

novemberborn
Copy link
Contributor

@novemberborn novemberborn commented Sep 29, 2016

I may have gotten a bit carried away with this… apologies :)

  • Uses Declarative DSL app#63
  • Includes todo-mvc: Deal with app refactor #54
  • Creates stores in their own module, wires them to the App declaratively
  • Actions refer to each other, and to stores, via module imports
  • Only the two actions used declaratively are registered with the App
  • UI is built declaratively
  • todo-item custom element is registered declaratively, though maybe it should be done in main.ts
  • Moved todo store observation code into the todo store module, perhaps the App should be able to do this
  • Moved routes to their own module
  • Perhaps the App should determine when the router is started
  • I've tried to type stores and actions. Action typing is a nightmare though

This was referenced Sep 30, 2016
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.
@novemberborn novemberborn changed the base branch from todo-app-refactor to master October 3, 2016 13:11
@novemberborn
Copy link
Contributor Author

The corresponding app PRs have been merged, so this should go out once app is released. Please set me know what to improve.

@rishson rishson added this to the 2016.10 milestone Oct 3, 2016
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).
Copy link
Contributor Author

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.

Copy link
Contributor Author

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 ?

@novemberborn novemberborn merged commit 08b3009 into master Oct 5, 2016
@novemberborn novemberborn deleted the todo-declaratively branch October 19, 2016 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants