Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

[Memo] Change notifications? #155

Open
jessegrosjean opened this issue Oct 17, 2018 · 2 comments
Open

[Memo] Change notifications? #155

jessegrosjean opened this issue Oct 17, 2018 · 2 comments

Comments

@jessegrosjean
Copy link

Maybe I'm missing something obvious, but is there an API (or plans for an API) to be notified of changes to the work tree. In particular if the work tree gets modified due to remote ops being applied how do I learn when that happens and what has changed.

@nathansobo
Copy link

Our original plan was to allow you to detect changes just by inspecting the state. So if you're rendering a tree view, you can just retrieve the entries and re-render. If you have 3 buffers open, you can call changesSince for just those buffers whenever operations get applied to see if any have changed. We're open to iterating on this plan based on feedback. Definitely would be interested in what might work better for you in your use case.

@jessegrosjean
Copy link
Author

I think the changesSince API is good for buffers. Could something similar be added to work_tree to report file changes in the work tree?

It's true I can just determine this all by inspecting state. But if I want to update the view in an animated fashion then I need to know which exact files were inserted/removed/etc. I could do that by diffing states, but it gets expensive and complicated. Especially when all the information is already known by memo, seems like just exposing exactly what's changed would be nicer.

My use case is that I'm building a macOS file tree view as a learning project. The view can be updated in two ways. Simple way is to just reloadData... which reloads the entire view. Works, but it's somewhat expensive and doesn't provide any animation. On the other hand if I know exactly which files are removed/inserted/changed then I can just reload those portions of the view that have changed. It's faster and you get animation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants