Comments (4)
LouisCAD, how you load data is irrelevant in that case. Agera makes it easy to get off the main thread, which is one reason to use Loaders. The other reason is surviving rotation, but to do this you can put the repositories in a retained fragment or in a scope outside the config change lifecycle as Max explained.
from agera.
Depending on the implementation of the repository. If it is a custom repository and it has quick access to a cached storage of the data, then it doesn't hurt too much to recreate it when the activity restarts -- just let it be initialized to the cached value if available.
Otherwise, you can consider using a UI-less fragment that retains its instance to keep the repository across activity restarts. The repository will likely still go through a deactivation and reactivation cycle, but any value from the last completed request can stay in the repository for use by the restarted activity instance. It can even keep the ongoing unfinished network request (only if this is appropriate) by not terminating the request when it is deactivated.
If this repository can likely benefit from being shared by multiple components (different activities and services) in your app, you can also consider making it a "global" (globally accessible instance), by means of static fields. But this decision needs to go through careful thinking -- you might end up retaining too much memory when the repository is not needed.
from agera.
"The repository will likely still go through a deactivation and reactivation cycle": Just did a change for this for the future 1.1.x release that will keep the repositories alive if deactivation and reactivation is registered in the same loop on the looper thread, meaning they will survive rotation and thus not do this extra update.
from agera.
Would agera repositories play well with Android loaders? Did anyone tried or is there such a sample?
from agera.
Related Issues (20)
- Compilation problems HOT 1
- Crash when trying to remove not added updatable HOT 1
- Add the 1.2.0 release to the GitHub releases screen HOT 1
- Exception when Response is Empty HOT 4
- [Question] Usages of non main thread to register an Updatable to a BaseObservable? HOT 5
- Wish to support Kotlin language.
- crash bug HOT 3
- About IdentityMultimap query. HOT 3
- Is this library dead? HOT 2
- [question] Push Event on a high speed frequency, Pull Data will too busy to attend to all HOT 2
- Query HOT 3
- [Query]: About switch work-thread HOT 10
- Agera 是否支持线程并发再合并? HOT 1
- #44
- (gradle4.4.1, agera1.4.0) when I run proguard, I got these warnings:
- Could not find dependency "com.google.android.agera:agera:1.4.0" HOT 6
- Sample doesn't build, is this project dead? HOT 7
- Androidx支持
- Deploy the last artifact outside of jcenter HOT 1
- Security Policy violation Binary Artifacts HOT 41
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from agera.