Comments (10)
Otherwise,I have a additation question:
I create a repository and while add some action on it, before the .compile() Agera will automatic add/implementation notifyIf and check old value and new value to check if need update.,right?
now,I want to execute their all directives only if observe()'s observable send a dispatch(). but now,I add a updatable while their directives will be execute,it's not my expect. I try to add golazy() and trigger get() to execute, and met other problem,if add golazy() and after can not add goto().. so still can't resolve problem.
I expect: only .observe(mOb) 's mOb to send dispatch() their all directives can be execute.
no expect: only add updatable their all directives can be execute.
please give me some help,thanks
from agera.
Connect above,
Because I need add some action on repository,so only use .repositoryWithInitialValue() not ..mutableRepository(). actually is CompiledRepository, and CompiledRepository extends BaseObservable and implementation ptotect method:observableActivated(), so just add Updatebale will be start.
from agera.
I can't fully understand your follow-up questions. Feel free to use Chinese and I'll translate your questions to English and then answer them in both languages.
About main-thread executor: you don't need to use a main-thread executor in the flow, unless for some reason you have to go back to the main thread to retrieve more data for your computation. When you've finished producing the value in the background thread, all observers will react on the main thread (if they were registered on the main thread).
from agera.
Sorry,my english is poor,I will be careful.
About main-thread executor: I know the updatable will be runing on registered thread when receive notify. For example: I create a repository and include some actions on it, such as getFrom、transfer、mergin.. ,I want to runing getFrom on non-mainThread,for this point,I can use goto(Executor) to do it, but if I do it,the rest of flows both runing on this thread.,now I want to running transfer on main-thread, how to do it, how to switch main-thread. and note: I have no use goLazy() so only all actions finished the updatable can be runing.
from agera.
About another problem:
I create a repository use mRep = Repositories.repositoryWithInitialValue(null)
, and then observe a Observable use .observe(mOb)
. and add some actions after it,such as getGrom,thransfter etc.
I expect: mRep's all actions start execute only when mOb to do dispatch()
rather than mRep.addUpdatable(this)
.
But I find mRep's actions will be start as long as execute mRep.addUpdatable(this)
, actually Repositories.repositoryWithInitialValue()
will be create a 'CompiledRepository' and this class also implementation 'observableActivated()',so I don't know how to handle this problem. and goLazy()
can't match my requirement,so can't use this.
from agera.
private object MainThreadExecutor : Executor {
private val handler = Handler(Looper.getMainLooper())
override fun execute(command: Runnable?) {
handler.post(command)
}
}
from agera.
Thanks @sfcecy7i !
On your second issue, the life cycle is described here. Basically, by design, and shouldn't be avoided. I think you need to reassess your design if this is what you need.
Also, you can't create a repository with null, you'll have to have a concrete default value
from agera.
@sfcecy7i @ernstsson Thanks!
from agera.
@likai79511, you can still hack the system into your will, using creativity :)
AtomicBoolean activatedOnce = new AtomicBoolean(false);
Repository<V> repository = repositoryWithInitialValue(initialValue)
.observe(obs)
.onUpdatesPer...
.check(_ -> activatedOnce.getAndSet(true)).orSkip() // creativity
.getFrom.....
......
.compile();
// in use site; suppose the repository will only have one updatable at most:
activatedOnce.set(false);
repository.addUpdatable(updatable);
repository.removeUpdatable(updatable);
from agera.
@maxtroy Thanks. use check()
to skip the rest of flows is very simply way and solve my problem.
I even thought to that override repositoryWithInitialValue
and extends CompiledRepository
.
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
- 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.