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

Add ability to listen to ids with Rocket Data #56

Open
plivesey opened this issue Jan 11, 2017 · 2 comments
Open

Add ability to listen to ids with Rocket Data #56

plivesey opened this issue Jan 11, 2017 · 2 comments

Comments

@plivesey
Copy link
Owner

For collection data providers, it'd be great to filter on model changes and insert them into the collection if they meet a certain filter. This would be like predicates in core data.

@hebertialmeida
Copy link
Contributor

Do you have an idea of how this could be possible, perhaps if it would be possible to listen for a type?

@plivesey
Copy link
Owner Author

Hmmm...looks like this may already be possible with data providers. It looks like you can create a DataProvider and set modelIdentifier. Then, once the model is available, it'll be set onto the data provider.

For the filter method, the easiest way seems to be to do this right after the data changes but before you notify any delegates? And it would just run it on the main thread before notifying listeners?

For listening to certain models for a collection data provider, you could use the consistency manager method:

    open func addModelUpdatesListener(_ updatesListener: ConsistencyManagerUpdatesListener) {
        modelUpdatesListeners.append(updatesListener)
    }

This basically fires for every single model change and so you could filter there. However, threading may be tough. Currently, it runs on the main thread:

     The `ConsistencyManagerUpdatesListener` methods are called on the **main thread** for every model updated in the system.
     It's recommended to do as minimal processing as possible here so you don't block the main thread.
     It's also recommended to have a small number of global listeners.

Maybe it's good enough to just filter on the main thread. Maybe you want to queue them up on a background thread but make sure they're in order (so you always get eventual consistency?)

It would be tough to manage because someone could also change the data on the data provider at any time? So...some ideas...some of this is certainly very tricky, but possible.

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

2 participants