Skip to content
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

Change events order #18

Closed
wants to merge 1 commit into from
Closed

Change events order #18

wants to merge 1 commit into from

Conversation

STAH
Copy link

@STAH STAH commented Oct 12, 2013

No description provided.

hashchange added a commit to hashchange/backbone.picky that referenced this pull request Jan 14, 2014
@hashchange
Copy link

I don't know what made you propose this, but I have wondered about it too while tracing a bug. In my opinion,

  • the order of events shouldn't matter at all. Whether the model event or the collection event fires first, is an implementation detail. If that kind of thing is important to your (or my) code, it is design flaw - a case of tight coupling.
  • the model event is triggered too early, though. At that point, the selected property in the associated collection hasn't been updated yet, leaving the model-collection combo in an inconsistent state. That can be a cause of bugs. Picky should notify external observers when it has done its thing, not somewhere in the middle of the process.

I have fixed it in my PR for model sharing among collections (issue #23). Tests are included.

hashchange added a commit to hashchange/backbone.picky that referenced this pull request Jan 15, 2014
@compojoom
Copy link

Hey guys,
Thank you for those PRs! I hope that Derick will look into them & finally give some love again to this repository.
I spent the afternoon trying to track a bug in my code.

In my view I'm listening to the model's selected and deselected properties and I'm changing the css of the selected elements. Long story short - I was using smooth scrolling to scroll to the currently selected element. All the time I couldn't understand why the scrolling was working as expected sometimes, where other times it was with around 40px off... And this is when I realized that Backbone.Picky was for some reason triggering select first, then it was deselecting the element. My scroll was working as expected, but since the deselected was removing a css class of the element - it was positioned wrong.

@hashchange - I tested your PR and with it Backbone.Picky started to emit the events in the order one would expect. Thanks!

@hashchange
Copy link

@compojoom Thanks for the feedback!

As things stand now, Backbone.Picky is no longer maintained - the latest activity was almost a year ago, and I haven't been able to get the attention of Derick on Twitter either.

I have written a successor to Backbone.Picky earlier this year. It actually started off as a collection of Picky PRs which were gathering dust, and it is maintained, so I'd encourage anyone to consider switching. I wouldn't normally tout my own stuff on somebody elses bug tracker, but running into bugs which have long since been fixed is just a waste of time for anyone.

So have a look at Backbone.Select if you wish. It's fully compatible with Picky except for the initialization code - see the section on compatibility in the docs.

@STAH
Copy link
Author

STAH commented Jun 11, 2014

3 months with Backbone.Select in production app (some small changes to migrate from Picky). Great work!

@STAH STAH closed this Jun 11, 2014
@hashchange
Copy link

@STAH :)

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

Successfully merging this pull request may close these issues.

3 participants