Comments (5)
I would do something like your first option. If /changes
returns o9
as updated and o1
as created (say), I would just invalidate both if they are cached in my store. Most of the time, anything in created
will not be cached (especially if you are using push; you are most likely to get a push, call /changes
and possibly fetch the created
in the same call using back references, but the objects will still be returned after the /changes
in the call), so there's not much to gain from trying to do something more clever.
If you are keeping track of state strings on a per-object rather than per-type basis (I don't, because you don't really need to in general) you could skip invalidating it if the object's state string matches the newState
of the /changes
response, as you suggest.
Does that make sense?
from jmap.
I would do something like your first option. If
/changes
returnso9
as updated ando1
as created (say), I would just invalidate both if they are cached in my store. Most of the time, anything increated
will not be cached (especially if you are using push; you are most likely to get a push, call/changes
and possibly fetch thecreated
in the same call using back references, but the objects will still be returned after the/changes
in the call), so there's not much to gain from trying to do something more clever.
The context here is in a webapp where you have cached the objects in IndexedDB. If the user clicks on a link to an object that is not cached (e.g. /items/123
) then it would be preferable if I can kick away a separate /get
request (potentially with fetching more data using back references) to improve the first load, and then in the background also do the regular syncing of existing cached data (so that if the user clicks on another page, then it's fast and swift). I'm aware that this isn't the use-case which JMAP was originally designed for, but it would be nice if there was a way to accomplish it.
If you are keeping track of state strings on a per-object rather than per-type basis (I don't, because you don't really need to in general) you could skip invalidating it if the object's state string matches the
newState
of the/changes
response, as you suggest.
Even if I have per-objet state tracking it's not possible to detect this today in the example I gave. The /changes
call returns the differences between [s1, s7]
and o1
is included there. I still don't know if it was changed after s5
(which is the object's latest state). This will also be a lot worse if the user uses the "return recent changes first" since it will create intermediate states that will not match neither s5
nor s7
.
from jmap.
Yes, this sounds fine. It depends on the application of course, but for most it should be fine to fetch the object and use the cached data while you do the rest of the sync in the background.
Even if I have per-objet state tracking it's not possible to detect this today in the example I gave. The /changes call returns the differences between [s1, s7] and o1 is included there.
Sorry, I must not have been clear. I'm saying the common case is likely to be the object from the /get was s7
and your /changes
call gives you [s1,s7]
. In this case, you don't need to invalidate the object. But it's really only a minor optimisation: yes you have to refetch any mutable properties and probably none have changed, but it's unlikely to be for many objects and unless each one is particularly large/expensive to fetch it won't add much overhead.
Example.
- Store has objects cached:
o1
,o2
,o3
…o99
with states1
. - User clicks link with id
o123
. - App fetches
o123
and gets the data in states3
. - App shows the data while in the background doing
/changes
froms1
. The ultimate state iss5
ando123
is included ascreated
in one of the pages of changes. - The app has to invalidate
o123
as it may have been updated since it was fetched, however refetching the mutable properties of one object is generally negligible, especially if you're bundling it in a request for updates to other invalidated objects.
from jmap.
Then it seems like I've understood how JMAP works today. I have some ideas for a slightly modified /changes
-semantics which could handle more complicate state-changes, but I'll leave that for now and will investigate it later if it turns out that over-fetching is a problem for my use case.
from jmap.
Sure, always happy to hear more ideas. Generally, there's a trade-off in terms of extra state data having to be transferred with every request in order to potentially save some data in certain resync cases later. Whether that's worth it will depend on the use case to a certain extent, but we've tried to pick a broadly applicable model for the base JMAP standard.
from jmap.
Related Issues (20)
- From Cyrus: use of EmailSubmission/set#onSuccess* without :mail capability HOT 1
- Require "urn:ietf:params:jmap:mail" capability when calling MDN/set? HOT 1
- update multiple records via ResultReference HOT 1
- Why is the Invocation type an Array? HOT 1
- Client and server guides seems to be outdated HOT 3
- VTODO support HOT 4
- bodyStructure on message/delivery-status HOT 1
- Future feature : quickly tell servers of a mail adress move HOT 2
- Question: Mandate core capability on each API call? HOT 1
- Question: Why isn't JMAP getting much traction? HOT 2
- Missing refs to RFC-8887 (JMAP over WebSockets) ? HOT 1
- Document authentication discovery on top of JMAP HOT 4
- Add WIP JMAP library? HOT 5
- Scheduled / delayed sending is not documented? HOT 3
- Does JMAP supports the FXP mode ? HOT 1
- Questions about JSON Pointer (result reference) HOT 2
- Ability to download original email content HOT 2
- Support for Task tags HOT 1
- RFC links are broken HOT 1
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 jmap.