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 API to fuse autodispose rx types and proxy interfaces #376

Merged
merged 7 commits into from
Sep 16, 2019
Merged

Conversation

ZacSweers
Copy link
Collaborator

Right now, AutoDispose will always create anonymous instances of *Proxy interfaces that that call through to underlying custom rx types (e.g. AutoDisposeObservable) that have the custom observer implementations. This was done defensively to prevent introspection and is similar to APIs like Observable.hide(), but does come at the cost of an extra allocation + virtual invocations at runtime.

We can save this allocation at the cost of the hiding behavior by just making the custom rx types implement their corresponding proxy interface and returning them directly. This is easy in code because they have matching subscribe signatures.

This PR adds a new plugin to control this hiding behavior via AutoDisposePlugins#setHideProxies(). The default is true, matching current behavior. If set to false, the rx types will be returned directly and unhidden (though casted as the proxy interface). This can be useful for those wanting to squeeze a little bit of extra juice at runtime.

@ZacSweers ZacSweers added this to the 1.4.0 milestone Sep 15, 2019
@ZacSweers ZacSweers self-assigned this Sep 15, 2019
@ZacSweers ZacSweers merged commit efdce68 into master Sep 16, 2019
@ZacSweers ZacSweers deleted the z/fusion branch September 16, 2019 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants