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

Feature request: add a remote:"never" option per save #138

Open
DaveSanders opened this Issue Apr 21, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@DaveSanders

This is an edge case for me, but I have a case where a user model is used for login and that is sent up to the server. I'd like to not have the user's password in the localstorage after the login, so I can easily go in and do a:

user.save({password:null}, {remote:false})

Which is fine, but then there is a dirty user record sitting out there, that will never be saved to the server. It would be better if I could specify a local change with a remote:'never' or some other option and then have that change never go into the dirty (or destroyed) queues for later syncing.

(Now that I'm typing this, I think I just realized I need to do a custom parse maybe so that I can blank out that password before local save - so this might be a nonsensical case - but its an idea nonetheless.)

@nilbus

This comment has been minimized.

Show comment
Hide comment
@nilbus

nilbus Apr 27, 2015

Owner

We were discussing this here: #12 (comment)

I had also said this, which you have just shown me was an incorrect assumption:

I don't believe we need any mode that uses local storage does not mark records dirty.

Accounting for that, what do you think about having a storageMode option with these options? I'm open to suggestions on the option names. Do they make the behavior obvious?

storageMode: mode # one of: ['dual' (default), 'offline', 'remote-only', 'local-only']
Owner

nilbus commented Apr 27, 2015

We were discussing this here: #12 (comment)

I had also said this, which you have just shown me was an incorrect assumption:

I don't believe we need any mode that uses local storage does not mark records dirty.

Accounting for that, what do you think about having a storageMode option with these options? I'm open to suggestions on the option names. Do they make the behavior obvious?

storageMode: mode # one of: ['dual' (default), 'offline', 'remote-only', 'local-only']

@nilbus nilbus added this to the 2.0 milestone Apr 27, 2015

@nilbus nilbus added the Improvement label Apr 27, 2015

@DaveSanders

This comment has been minimized.

Show comment
Hide comment
@DaveSanders

DaveSanders Apr 27, 2015

I think those work ok. I can't think of a reason why I would use remote-only right now, but it makes sense for completeness. I think the names work fine if their use is documented.

I'm not sure I understand what offline is for?

I'm a little bit confused - would these used in conjunction with the "remote: false" or as a replacement? If a replacement, then I agree this is a better system - providing the decision can be made broadly at the model AND at the individual record save.

Again, I'm dealing with a weird edge case, so I hate to pollute the pool with that. But if there are other uses then making sure to have a local-only for completeness would help my case.

I think those work ok. I can't think of a reason why I would use remote-only right now, but it makes sense for completeness. I think the names work fine if their use is documented.

I'm not sure I understand what offline is for?

I'm a little bit confused - would these used in conjunction with the "remote: false" or as a replacement? If a replacement, then I agree this is a better system - providing the decision can be made broadly at the model AND at the individual record save.

Again, I'm dealing with a weird edge case, so I hate to pollute the pool with that. But if there are other uses then making sure to have a local-only for completeness would help my case.

@nilbus

This comment has been minimized.

Show comment
Hide comment
@nilbus

nilbus Apr 27, 2015

Owner

I will document the options regardless, but I hope to make the option names make sense without having to refer to documentation.

These would replace both the local and remote options. storageMode: 'offline' would be equivalent to how remote: false acts now: it skips the online step, makes the changes locally, and marks the records dirty. Does this table make it clear?

storageMode option online sync ($.ajax) localstorage update mark records dirty current equivalent
dual (default) if offline default
offline remote option false AND local attribute falsey
local-only remote option false AND local attribute truthy
remote-only remote attribute truthy
Owner

nilbus commented Apr 27, 2015

I will document the options regardless, but I hope to make the option names make sense without having to refer to documentation.

These would replace both the local and remote options. storageMode: 'offline' would be equivalent to how remote: false acts now: it skips the online step, makes the changes locally, and marks the records dirty. Does this table make it clear?

storageMode option online sync ($.ajax) localstorage update mark records dirty current equivalent
dual (default) if offline default
offline remote option false AND local attribute falsey
local-only remote option false AND local attribute truthy
remote-only remote attribute truthy
@DaveSanders

This comment has been minimized.

Show comment
Hide comment
@DaveSanders

DaveSanders Apr 27, 2015

Yep, that makes sense!

Yep, that makes sense!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment