falcor icon indicating copy to clipboard operation
falcor copied to clipboard

refreshing() mode on the model for get requests

Open jordanna opened this issue 11 years ago • 13 comments

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:

  • get on a path that does not yet exist in cache will onNext the value(s) once fetched, i.e. same behavior as "non-refreshing" mode
  • get on a path that already exists in cache will onNext the value(s) from cache immediately, then fetch remote updated value(s), update the cache, and onNext when 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.

jordanna avatar May 01 '15 21:05 jordanna

@jhusain, @trxcllnt, @michaelbpaulson What is the level of effort to implement? I've added this to the Funktional Complete milestone

ktrott avatar May 01 '15 22:05 ktrott

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?

trxcllnt avatar May 01 '15 22:05 trxcllnt

That sounds good to me. Any unnecessary re-renders (i.e. updates to generation) will improve the UX.

jordanna avatar May 01 '15 22:05 jordanna

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.

jhusain avatar May 02 '15 23:05 jhusain

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?

huang47 avatar May 03 '15 03:05 huang47

@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?

ThePrimeagen avatar May 04 '15 16:05 ThePrimeagen

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 avatar May 04 '15 16:05 jhusain

@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?

ThePrimeagen avatar May 04 '15 19:05 ThePrimeagen

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.

jhusain avatar May 04 '15 19:05 jhusain

Falcor meeting (@jhusain, @trxcllnt, @sdesai): Agreed that it should de-dupe.

ktrott avatar May 04 '15 20:05 ktrott

@ktrott @jhusain @trxcllnt what is it in this context?

ThePrimeagen avatar May 04 '15 22:05 ThePrimeagen

@michaelbpaulson It is refresh mode. Agreed that refresh mode should de-dupe.

ktrott avatar May 06 '15 19:05 ktrott

Closing as this is no longer needed. Could be useful in the future, but we shouldn't increase the API surface area speculatively.

steveorsomethin avatar Aug 01 '17 16:08 steveorsomethin