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

Cleanup extensions #75

Merged
merged 4 commits into from
Apr 5, 2022
Merged

Cleanup extensions #75

merged 4 commits into from
Apr 5, 2022

Conversation

Goooler
Copy link
Owner

@Goooler Goooler commented Apr 5, 2022

No description provided.

@Goooler Goooler added this to the 1.6.0 milestone Apr 5, 2022
Comment on lines +271 to +272
inline fun <reified V, reified VM : BaseViewModel> V.baseViewModels(): Lazy<VM>
where V : LifecycleOwner, V : ViewModelStoreOwner = lazy(LazyThreadSafetyMode.NONE) {
Copy link
Owner Author

Choose a reason for hiding this comment

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

@MainThread
public inline fun <reified VM : ViewModel> Fragment.viewModels(
    noinline ownerProducer: () -> ViewModelStoreOwner = { this },
    noinline factoryProducer: (() -> Factory)? = null
): Lazy<VM> = createViewModelLazy(
    VM::class, { ownerProducer().viewModelStore },
    factoryProducer ?: {
        (ownerProducer() as? HasDefaultViewModelProviderFactory)?.defaultViewModelProviderFactory
            ?: defaultViewModelProviderFactory
    }
)

Copy link
Owner Author

Choose a reason for hiding this comment

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

Todo: remove LifecycleObserver from BaseViewModel.

@Goooler Goooler merged commit 6ced636 into trunk Apr 5, 2022
@Goooler Goooler deleted the extensions branch April 5, 2022 16:13
@Goooler Goooler mentioned this pull request Apr 5, 2022
ViewModelProvider(this)[VM::class.java].apply(lifecycle::addObserver)
}

@MainThread
inline fun <reified V, reified VM : BaseThemeViewModel> V.getThemeViewModel(): Lazy<VM>
inline fun <reified V, reified VM : BaseThemeViewModel> V.themeViewModels(): Lazy<VM>
Copy link
Owner Author

@Goooler Goooler Apr 5, 2022

Choose a reason for hiding this comment

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

Todo: refactor to what viewModels like.

@Goooler Goooler mentioned this pull request Apr 8, 2022
Goooler added a commit that referenced this pull request Apr 11, 2022
This was referenced Apr 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant