NGRX Offline patterns #3089
Replies: 8 comments 1 reply
-
Hey is there any update on this? Can we expect this soon? |
Beta Was this translation helpful? Give feedback.
-
Do you think this can be doable with the new pipe in What do you think? |
Beta Was this translation helpful? Give feedback.
-
@MattiJarvinen interesting thooughts. Appreciate it. I'm about to dig into this topic and any updated guidance is appreciated. Thank you guys. 🙏 |
Beta Was this translation helpful? Give feedback.
-
Hi @leonardochaia Cheers |
Beta Was this translation helpful? Give feedback.
-
Hi @wundo, unfortunately I was delayed with other projects and haven't been able to dig into this. It's still on the backlog so I'll definitively take a look soon. |
Beta Was this translation helpful? Give feedback.
-
@leonardochaia any update on progress or findings? Personally I think if we're going to look at offline, let's do it properly with an offline storage like indexeddb. At least that's my opinion. And thinking more fully about offline (imagine 8 hours offline rather than intermittent) forces us to cover more bases. page 45 of Online and Offline Operation ofJ2EE Enterprise Applications details the possible out-of sync states for a local and replica of a data object (or entity in our framework thinking) and outcomes/conflicts which I've put below. Local down, replica across. Replica is most likely the server but could be any two data stores of objects you want to sync. Most of bracketed terms can occur if there is more than one data store (think sever iPad, desktop etc)
I've replaced the clear state for unchanged and modified for updated to match @ngrx/data. Synchronization ProcessStore A sends list of updates (Added / Updated / Deleted) to Store B "The resolution of a conflict is called reconciliation and is always performed on the data store receiving updates from another data store." Conflict StrategyClient Wins Upshot is that if |
Beta Was this translation helpful? Give feedback.
-
Hello @AdditionAddict , I have been following this thread of offline and sync design and recently looked at the issue number 2359 that you closed on the @ngrx/data side, after the team showing no interest in adding the sync capabilities. Just out of curiosity have you been still working on it? Would love to hear about it, regards! |
Beta Was this translation helpful? Give feedback.
-
@samratarmas I'm currently exploring ideas. To be fair to the team they can't work with wishy washy proposals that are already covered by change tracking (didn't know this in depth at the time). They need concrete ideas that won't affect current users negatively and falls within reactive scope. I still think @ngrx/data is the basis on which to proceed rather than start from scratch, but it may be a case of breaking into it at key points by extending some current classes and providing the suite of classes to deal with offline behaviour. The main crux with the current codebase is that the main Therefore to support offline first means extending
My current implementation is to mimick Current ModelPotential ModelThere are natural patterns for switching between 'Online' or 'Offline' modes combining naviator.online (converted to stream of course), a user toggle if they wish to have more direct control and an API circuit breaker pattern based of Angular Design Patterns by Mathiey Nayrolles page 119 Saturating storeFor each store / entityName:
Offline BehaviourAdd / Delete / Update → app uses NgRx, persist via IndexedDB / localStorage (main thing will be API that could be implemented separately by user) Online BehaviourI need to think more carefully about this but roughly speaking (for my use case anyway)
I'm currently struggling with is indexeddb and understanding the current @ngrx/data codebase to the level I need to (not looked at architecture in this manner before) and need to layout the models more concretely. Next step is to lay everything out in typescript models... |
Beta Was this translation helpful? Give feedback.
-
I'm submitting a...
What is the current behavior?
We currently have no documented patterns for handling offline Effects calling remote services.
Expected behavior:
We should start discussion on ideas on how to handle offline state changes. Maybe that way we as a developer community get past the we're working on it and more immediate matters taking most of our time.
Other information:
I tried to device most used problem scope, without entity relations to keep things simple at first.
NGRX offline pattern optimistic effects with outbox:
Here I'm trying to describe possible logic for an retry outbox based logic. This example is not complete and I have currently no real idea on how to handle following cases:
Some actions that are perhaps the most needed for offline use are:
Offline execution of Actions & Reducers & Effects
State description:
CREATE
UPDATE
DELETE
If outbox != empty and we're "online" retry FIFO outbox action with decaying retry interval ( up to a point like max 30min interval or so).
On logout clear outbox... everything in the outbox is lost.
Beta Was this translation helpful? Give feedback.
All reactions