badoo / MVICore

MVI framework with events, time-travel, and more
https://badoo.github.io/MVICore/
Other
1.24k stars 86 forks source link

AndroidTimeCapsule in example app #70

Open simonvar opened 5 years ago

simonvar commented 5 years ago

In MVI core demo app you pass AndroidTimeCapsule in Feature2 through constructor.

class Feature2(
    timeCapsule: TimeCapsule<Parcelable>? = null
) : ActorReducerFeature<Wish, Effect, State, News>(
...

How it supposed to be used with Android lifecycle methods onRestoreInstanceState and onSaveInstanceState?

ShikaSD commented 5 years ago

@simonvar Not sure why it was not done in the example app, but the usage is quite straightforward.

You can create AndroidTimeCapsule instance in onCreate of your activity and pass it to the feature constructor. Then in onSaveInstanceState call saveState method on the capsule. You can see an example here.

simonvar commented 5 years ago

@ShikaSD Is there another approaches when i inject feature?