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

Update model watcher dsl to support sealed classes #112

Merged
merged 12 commits into from Oct 8, 2019

Conversation

ShikaSD
Copy link
Contributor

@ShikaSD ShikaSD commented Sep 25, 2019

Achieved my delegating subclass diff implementation to other instances of model watcher.

  • Added clear method as a part of public API of ModelWatcher<T>.
  • Added type and objectType DSL methods for ModelWatcher.Builder<T>

Example:

modelWatcher<Model> {
    type<Model.A> {
        Model.A::field { 
            // Do stuff
        }
    }
    objectType<Model.B> { modelB ->
        // Do stuff
    }
}

Fixes #111


fun clear() {
model = null
childWatchers.values.forEach { it.clear() }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to change it to clearChildren method?

@zsoltk zsoltk merged commit 6911b75 into badoo:master Oct 8, 2019
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.

Best practices for using ModelWatcher with sealed class ViewModel
3 participants