-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds onFirstListener and onNoListener callbacks
These callbacks allow anything extending `Backbones.Events` to be notified when something starts listening to it, and when nothing is left listening to it. Because of `internalOn` this is hard to implement in user land. The use case for this is if you had a Model presenting the output of an expensive continuous calculation (say real time Stock Prices or a timer). The `onFirstListener` function can be used to start your expensive calculation, as you only care about it while the something is listening to changes in it. When that item stops listening to changes in it, `onNoListeners` will trigger, allowing you to clean up your code (unsubscribe the stock price, or stop the timer or even stop listening to another Event).
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# EditorConfig: http://EditorConfig.org | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
raw | ||
*.sw? | ||
.DS_Store | ||
.idea | ||
node_modules | ||
bower_components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters