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

Remove Coroutines from public API & introduce Coroutines and Reactive modules #57

Merged
merged 4 commits into from
Feb 21, 2022

Conversation

alexstyl
Copy link
Owner

@alexstyl alexstyl commented Feb 21, 2022

This PR removes any Coroutine suspend or Flows from the public API of ContactStore.

Instead of the Flow, the API exposes a new FetchRequest object, which allows the consumers to either get the result in a block manner throughblockingGet() or collect() in an asynchronous fashion.

Example of usage:

val fetchJob = contactStore.fetchContacts()
    .collect {
        state.value = Loaded(it)
    }

// onDestroy()
fetchJob?.cancel()

similarly, the fetchContactGroup() function returns a FetchRequest which emits a list of ContactGroup.

The PR also intoduces 2 new modules: coroutines and reactive. The modules contain extension functions for those that are familar working with coroutines and rx-java3 respectively.

Example of usage using the coroutines extensions:

val job = contactStore.fetchContacts().asFlow()
    .collect {
        state.value = Loaded(it)
    }

// onDestroy()
job?.cancel()

example of usage using reactive extensions:

val disposable = contactStore.fetchContacts().asFlowable()
    .subscribe {
        state.value = Loaded(it)
    }

// onDestroy()
disposable?.cancel()

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.

None yet

1 participant