Skip to content
This repository was archived by the owner on May 2, 2019. It is now read-only.

Silent set functionality for objects #28

Closed
wants to merge 3 commits into from
Closed

Conversation

Neogavin
Copy link

@Neogavin Neogavin commented Feb 1, 2013

Been using Stapes for a project here at work, and was wondering why this wasn't a feature already: Implement silent set functionality for objects as well as individual values.

Because sometimes, I want to update a model without having it notify everything else right away.

Also showed an alternative way to handle the silent flag existing or not.

Implement silent update functionality for objects as well as individual values.
@yocontra
Copy link

yocontra commented Feb 2, 2013

Doesn't this already exist? I see tests for this too

@Neogavin
Copy link
Author

Neogavin commented Feb 2, 2013

http://jsfiddle.net/Neogavin/3WPYS/5/

Here's a jsfiddle that shows the problem exactly. If you set/update using an object, the silent flag is ignored.

@hay
Copy link
Owner

hay commented Feb 4, 2013

Hey Neogavin, thanks for your pull request!

Right now the silent option is not just a argument for set, but also for push, remove and update. IMHO, adding the flag for objects in set would also require adding it for those three other functions. I'm not sure if the use case is big enough. Note that if you want, you can pretty easily monkeypatch Stapes to have the functionality you want using the Stapes.extend method.

@Neogavin
Copy link
Author

Neogavin commented Feb 5, 2013

That's how I'm currently using it on my project. I just think it'd be more consistent for the silent flag to always work, and not just in the case of setting/pushing/removing/updating one attribute. And its a small enough change that I could literally do it in a few minutes and commit it.

I can understand it not seeming like a very big use case right now, but this was something that threw me off for a while, and I am using it in a production environment, so I'm sure someone else will want this feature added in at some point. I could submit another pull request with the change already in it if needed.

@yocontra
Copy link

yocontra commented Feb 6, 2013

I agree with @Neogavin it seems like inconsistent behavior for set to not obey the silent flag in a case as standard as this. If you want to initialize a bunch of properties on init but don't want it to trigger a bunch of events off (which seems like it is what you would want to do) it seems like overkill to write a bunch of .set calls instead of one

Added in chaining functionality for on/off events.  Just returns the Stapes.subclass when you set an event to on/off.
@Neogavin
Copy link
Author

Neogavin commented Feb 8, 2013

Oh, shoot, that last commit was an error, I put it on the wrong branch.

That was my mistake.
@hay
Copy link
Owner

hay commented Feb 8, 2013

Okay, the use case seems legit, and i agree that it's probably easy to implement. However, i'll only accept a pull request if:

  • You implement the feature for set, push, remove and update.
  • You add some simple unit tests (see test directory)
  • You add it to the docs.

I'll be closing this PR for now, if you got something, please open a new one. I'm looking forward to your contributions and thanks for all your comments on Stapes!

@hay hay closed this Feb 8, 2013
hay added a commit that referenced this pull request Jul 9, 2013
@hay
Copy link
Owner

hay commented Jul 9, 2013

Well, i was a little harsh last time, it didn't actually take the time i thought to code it, so i rolled in silent functionality for objects in set in the latest release, v0.8.0, which i've released just now! Thanks for your suggestion and PR!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants