Allowing Optional IDs in withEntities Function #435
Unanswered
AdmilsonCossa
asked this question in
Q&A
Replies: 1 comment
-
You can use the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Imagine a scenario where you're working on an application that needs to save a model in local storage before sending it to a remote server or API once the internet connection is restored. For example, let's say you're building a quiz application that can be accessed offline, but the results of the quiz need to be sent to the server as soon as the user regains internet connectivity.
the withEntities only accepts non-null values, and we would like to pass an optional id in cases where the task hasn't been saved to the server yet but has an offlineId generated using nanoid or some other method.
Here's an example of what you'd like to be able to do:
const store = createStore( { name: 'Task' }, withEntities<ITask, 'id' | 'offlineId'>({ idKey: 'id' },{ idKey: 'offlineId' } ), withCollectionIds(), );
Do you know of a better approach to accomplish this, or is there a reason why this isn't currently implemented in withEntities?
Beta Was this translation helpful? Give feedback.
All reactions