Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Intro
With version 2.0 for every resource we would access (via
Reactor
'sfetch
), it would be "loaded from" and "saved to" to the same place. This was due to howInDiskPersistence
was created (with apersistencePath
). Having aresource
as input for thefetch
, is wrong as well, because it implies that there is a different behaviour, depending on the resource, in terms of persistence. The correct way, would be to fix theresource
when theReactor
is created.Example
A ViewModel that accesses different sections: Sports, Fashion and World news. With 2.0 we would need a reactor for each section. With this new approach, we only need one instance.
Changes
From a code perspective:
InDiskPersistenceHandler
, doesn't have any property now. It could actually be converted to free functions.ReactorFlow
is no longer responsible for deciding if persistence should be used or not.Reactor
methods, now have the responsibility to decide if it should be persisted and if so, what input they should receive.