refreshing() mode on the model for get requests
The internal version that is currently in production (mobile, website UIs) allows us to put the model in a "refresh" mode, which has the following behavior:
geton a path that does not yet exist in cache willonNextthe value(s) once fetched, i.e. same behavior as "non-refreshing" modegeton a path that already exists in cache willonNextthe value(s) from cache immediately, then fetch remote updated value(s), update the cache, andonNextwhen done
It is currently being used to refresh bookmark, rating, and other volatile data on M/SDP launch. The reason we cannot use an invalidation + get approach is because the UI can perform a top-down update while a request is still in-flight. For example, rotating an iPad will cause the M/SDP to re-render without bookmark, rating, and other data that is being updated, but no longer in cache.
@jhusain, @trxcllnt, @michaelbpaulson What is the level of effort to implement? I've added this to the Funktional Complete milestone
This isn't difficult to implement as @jordanna is describing, but we may want to fold in the work we're doing for de-duping values too. Then, the cached values would onNext immediately, we'd re-request them from the server, but would only onNext new values/values that have changed.
@jordanna @jhusain what do you guys think of this idea?
That sounds good to me. Any unnecessary re-renders (i.e. updates to generation) will improve the UX.
Can you clarify? If I set a path to the same value, I get notified immediately after it is set in the cache. However I do not get notified if it gets sent back successfully from the server. Is this correct? If so, I'm on board.
JH
On May 1, 2015, at 3:35 PM, Paul Taylor [email protected] wrote:
This isn't difficult to implement as @jordanna is describing, but we may want to fold in the work we're doing for de-duping values too. Then, the cached values would onNext immediately, we'd re-request them from the server, but would only onNext new values/values that have changed.
@jordanna @jhusain what do you guys think of this idea?
— Reply to this email directly or view it on GitHub.
may I know how we know if the data is being changed/updated in falcor? I might be wrong but my understanding is if it's an immutable object, even though there are multiple onNext was emitted we can still do it in react shouldComponentUpdate (w/ PureRenderMixin) to prevent re-rendering, is it correct?
@jhusain @trxcllnt The get behavior is simple to implement. The set behavior is? Could we get the definition of that and i could complete this task quickly.
Second: This would be a great time to fix the progressive problems where selector functions cannot be in progressive mode. Since progressive mode has to be on the model, IE model.toProgressive() does this mean that refresh mode will have to be the same? I suppose so. Just looking for confirmation from either @jhusain @trxcllnt
Third: Should we have a refresh vs progressive mode? Or should they be collapsed to just be refresh mode?
Yes put the progressive and refresh option on the model. However we cannot collapse refresh and progressive. Progressive gives you the data in the cache and then the missing paths from the server. Refresh gives you the data in the cache, and then the latest version of all the data on the server. We need users to be able to decide to opt in or out of that over fetching. Progressively and refresh should both diff, never sending the same PathValue twice. In JSON or JSONG mode, they should only onNext twice if there is at least one new piece of data with a different value than the last onNext. However in JSON and JSON Graph mode we should onNext all the data we have every time. I don't have a preference about whether we mutate the JSON object we sent last time, or create a new one. Seems like the latter would be faster.
@jhusain I we should really consider some of those changes you are proposing as they would really increase the complexity of set and refresh mode. @trxcllnt would you care to comment?
Sorry maybe I'm not understanding. I thought my proposal was identical to the one @trxcllnt proposed in the thread above. @trxcllnt can you clarify? Thanks.
Falcor meeting (@jhusain, @trxcllnt, @sdesai): Agreed that it should de-dupe.
@ktrott @jhusain @trxcllnt what is it in this context?
@michaelbpaulson It is refresh mode. Agreed that refresh mode should de-dupe.
Closing as this is no longer needed. Could be useful in the future, but we shouldn't increase the API surface area speculatively.