This repository has been archived by the owner on Aug 13, 2021. It is now read-only.
Updated backbone-to-sails to be compatible with Sails v0.10 #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The biggest change was adding the ability to listen to messages sent from a specific Model (as opposed to interpreting all incoming messages in the 'comet' event). For example, to listen for messages from Twinkie:
'comet' messages are still available and are the default if no socket message callbacks are supplied.
The only bit of visible overhead that's been added is the initBackbone() function which must be called AFTER the socket connection is made and BEFORE you begin working with Backbone. Here's an example:
In order to listen for messages about a specific Model, you pass in an Object as the first argument to initBackbone() that maps Model names with callback functions that trigger a Backbone event:
It's not the most elegant way to go about it but I haven't found a better way that doesn't rely on generating functions from strings using eval(). For example, it would be possible for initBackbone() to accept an array of event names:
which is much easier on the eyes but it would rely on using:
in the background. If anyone knows of a better looking way to accomplish this I'd love to hear it. Let me know what you all think!