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

fix(deps): update deps.kmpviewmodel.version to v0.7.0 #139

Merged
merged 1 commit into from
Feb 25, 2024

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Feb 25, 2024

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
io.github.hoc081098:kmp-viewmodel-savedstate 0.6.1 -> 0.7.0 age adoption passing confidence
io.github.hoc081098:kmp-viewmodel 0.6.1 -> 0.7.0 age adoption passing confidence

Release Notes

hoc081098/kmp-viewmodel (io.github.hoc081098:kmp-viewmodel-savedstate)

v0.7.0

Compare Source

Update dependencies
kmp-viewmodel and kmp-viewmodel-savedstate
  • New: Add support for Kotlin/Wasm (wasmJs target) πŸŽ‰.
  • The behavior of ViewModel.addCloseable(Closeable) on non-Android targets has been changed to be consistent with Android target.
    ViewModel's addCloseable() now immediately closes the Closeable if the ViewModel has been cleared.
    This behavior is the same across all targets βœ….
kmp-viewmodel-koin
  • Fixed: koinViewModelFactory: CreationExtras passed to ViewModelFactory.create will now be
    passed to the constructor of the ViewModel if it's requested.

    class MyViewModel(val extras: CreationExtras) : ViewModel()
    val myModule: Module = module {
      factoryOf(::MyViewModel)
    }
    
    val factory = koinViewModelFactory<MyViewModel>(
      scope = KoinPlatformTools.defaultContext().get().scopeRegistry.rootScope,
    )
    val extras = buildCreationExtras { /* ... */ }
    
    val viewModel: MyViewModel = factory.create(extras)
    viewModel.extras === extras // true <--- `viewModel.extras` is the same as `extras` passed to `factory.create(extras)`
Example, docs and tests
  • Add more tests to kmp-viewmodel-compose (android & jvm), kmp-viewmodel-koin (common),
    and kmp-viewmodel-koin-compose (common & jvm).

v0.6.2

Compare Source

Update dependencies
Added kmp-viewmodel-koin and kmp-viewmodel-koin-compose artifacts
  • For more information check out the docs/0.x/viewmodel-koin-compose

  • The Koin dependencies are used in kmp-viewmodel-koin-compose:

    • io.insert-koin:koin-core:3.5.3.
    • io.insert-koin:koin-compose:1.1.2.
  • New The kmp-viewmodel-koin artifact provides the integration of kmp-viewmodel, kmp-viewmodel-compose and Koin,
    helps us to retrieve ViewModel from the Koin DI container without manually dependency injection.

    class MyRepository
    
    class MyViewModel(
      val myRepository: MyRepository,
      val savedStateHandle: SavedStateHandle,
      val id: Int,
    ) : ViewModel() {
      // ...
    }
    
    val myModule: Module = module {
      factoryOf(::MyRepository)
      factoryOf(::MyViewModel)
    }
    
    @&#8203;Composable
    fun MyScreen(
      id: Int,
      viewModel: MyViewModel = koinKmpViewModel(
        key = "MyViewModel-$id",
        parameters = { parametersOf(id) }
      )
    ) {
      // ...
    }
Added type-safe API for SavedStateHandle
  • For more information check out the docs/0.x/viewmodel-savedstate-safe

  • New The kmp-viewmodel-savedstate artifact provides the type-safe API
    that allows you to access SavedStateHandle in a type-safe way.

    private val searchTermKey: NonNullSavedStateHandleKey<String> = NonNullSavedStateHandleKey.string(
      key = "search_term",
      defaultValue = ""
    )
    
    // Use `SavedStateHandle.safe` extension function to access `SavedStateHandle` in a type-safe way.
    savedStateHandle.safe { it[searchTermKey] = searchTerm }
    savedStateHandle.safe { it.getStateFlow(searchTermKey) }
    
    // Or use `SavedStateHandle.safe` extension property to access `SavedStateHandle` in a type-safe way.
    savedStateHandle.safe[searchTermKey] = searchTerm
    savedStateHandle.safe.getStateFlow(searchTermKey)
kmp-viewmodel-compose artifact
  • New Add rememberViewModelFactorys to remember the ViewModelFactorys in @Composable functions.
    They accept builder: @&#8203;DisallowComposableCalls CreationExtras.() -> VMs.
class MyViewModel(savedStateHandle: SavedStateHandle): ViewModel()

@&#8203;Composable
fun MyScreen() {
  val factory: ViewModelFactory<MyViewModel> = rememberViewModelFactory {
    MyViewModel(savedStateHandle = createSavedStateHandle())
  }
  val viewModel: MyViewModel = kmpViewModel(factory = factory)
  // ...
}
  • New Add a new kmpViewModel overload that accepts factory: @&#8203;DisallowComposableCalls CreationExtras.() -> VM
    (Previously, it only accepts factory: ViewModelFactory<VM>).

    class MyViewModel(savedStateHandle: SavedStateHandle): ViewModel()
    
    @&#8203;Composable
    fun MyScreen(
      viewModel: MyViewModel = kmpViewModel {
        MyViewModel(savedStateHandle = createSavedStateHandle())
      }
    ) {
      // ...
    }

The above kmpViewModel uses rememberViewModelFactory internally.
Use rememberViewModelFactory { ... } and kmpViewModel(factory = factory)
is the same as using kmpViewModel { ... }.


Configuration

πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

πŸ”• Ignore: Close this PR and you won't be reminded about these updates again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@hoc081098 hoc081098 merged commit 59f1eca into master Feb 25, 2024
4 of 6 checks passed
@renovate renovate bot deleted the renovate/deps.kmpviewmodel.version branch February 25, 2024 10:39
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.

None yet

1 participant