-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
except not filtering change #29
Comments
Think about this carefully. Think really carefully about what you are doing and you will see why there is an infinite loop. Hint: Your autosave concept is alittle bit aggressive |
I don't think my autosave is aggressive at all. When isDirty goes active, I request a save. The save yields for 3 seconds. If there is another change, the save will be pre-empted and a new one scheduled. It's not until there is no change for three seconds that the model is actually saved. It is at that time that I set updatedOn. The problem is that setting updatedOn is causing isDirty to go active even though updatedOn is in the list of "except". I assert that either except is not working correctly, or my understanding of except is wrong. |
Can you show me that model definition? Therefore isDirty tracks everything so you can tell if the model is changed and can do things if you like with that info. Not sure if it makes sense to change that?? Got any thoughts on this. |
@BryanHunt , I am actually starting to like your autosave method. It is pretty interesting. Do you have any thoughts on wether the except should refer to the isDirty? I am wondering why this issue even occurs because by the time autosave is called the model will be isDirty (true) so setting updatedOn should not affect anything at all. So that was puzzling. Anyway .. let me know what you think, or what I should I look into more, or close the issue. If you want to get on slack and talk about it, that is fine by me as well. |
I updated my model to include an except on the "updatedOn" field so I could set it when the model is saved. Now, when I save the model, I get into an infinite loop with updatedOn flagged as changed.
Here is the model config:
changeTracker: { trackHasMany: true, auto: true, enableIsDirty: true, except: ['updatedOn'] }
Here is the save code:
And the output from the console:
The text was updated successfully, but these errors were encountered: