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

Use a stable key to guard against data loop #57

Open
ef4 opened this issue Mar 13, 2016 · 0 comments
Open

Use a stable key to guard against data loop #57

ef4 opened this issue Mar 13, 2016 · 0 comments

Comments

@ef4
Copy link
Contributor

ef4 commented Mar 13, 2016

The data-loop defenses in the mobiledoc-editor component (_localMobiledoc and _upstreamMobileDoc) aren't sufficient to guard against many possible data loops, so it's easy to lose cursor position.

We could use an explicit document key/id instead. In practice, there is usually a good key laying around, like:

{{mobiledoc-editor mobiledoc=post.body key=post.id on-change=(action (mut post.body))}}

The above example would only rebuild the editor if key changes. It would safely ignore any of its own changes that come back down.

I implemented this pattern in a component that wraps mobiledoc-editor and it seems to work well.

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

No branches or pull requests

1 participant