Skip to content

Abstract the data path #4

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ctford
Copy link

@ctford ctford commented Dec 13, 2015

In the example you presented at ClojureX, knowledge of the core.async channel and the location of the counter's state leaked into the messages and view.

I've refactored this example to remove that coupling. handle-with! is a piece of generic machinery that uses an fmap function and a view function to wire up a component to where to find its state in the overall model. This could easily be pushed into Petrol's core, and possibly replace send!.

You could easily write helpers that would construct fmap and view from a path, though it's not necessary that they use a path at all - you might want to e.g. use a model containing seconds with a component that expects minutes.

This may or may not match your plans for Petrol, but I thought it would be fun to use lens functions to make the wiring up simpler.

@ctford
Copy link
Author

ctford commented Dec 13, 2015

Thinking about it, handle-with! could also be written in terms of get and set, rather than update. Might make it simpler to grok?

And if you rolled it into core, you could keep ui-channel private.

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.

1 participant