marionettejs / backbone.radio Goto Github PK
View Code? Open in Web Editor NEWMessaging patterns for Backbone applications.
License: MIT License
Messaging patterns for Backbone applications.
License: MIT License
Quickly looking through it seems like theres some inconsistency of what is being returned when. We should look through it all and make sure its what we want.
It would be useful to have an option to add retrospective listeners to events that have already fired for occasions when you don't know the order in which events will be fired / listeners have been added.
There's an interesting example of this at https://github.com/facebook/emitter#holding
There should be handy methods to attach hashes to the messaging systems, just like we could do in Wreqr.Radio.
I'm not entirely sold on the idea myself, but I'll try to make an argument for it since so many Backbone projects do this.
I was just looking at the built file and got thinking that putting everything in one file makes it read rather nicely. Take a minute and read through the ~270 lines of actual code:
https://github.com/jmeas/backbone.radio/blob/master/build/backbone.radio.js
I think that maybe having a bunch of source files makes the library seem larger than it really is, and maybe less approachable.
Our documentation is extensive, however I think a great many people simply read through the source in order to fully understand what the library is doing in the background.
I think it would also reason that we do things that are actually private instead of _private
. Such as _debugLog
or the upcoming _eventsApi
. Two methods that would be weird to override. The reason we don't currently do this is for jshint (which is a weak reason).
For the UMD testing, I think we can probably find another way to keep our coverage at 100%.
@jmeas What do you think?
Utilize them wrapper beforeEach
and afterEach
functions
//cc @thejameskyle
The once
methods should pass things off to the on
methods, not the trigger
methods.
This flew under the radar because there are no tests for this behavior. Code coverage would have helped here :(
The factory function was a neat exercise in merging the two channels, but it is ultimately limiting due to the complexity involved in making unique behavior between Commands and Requests.
At the expense of a larger library I should get rid of the factory and duplicate the code.
"bugs": {
- "web": "https://github.com/jmeas/backbone.radio/issues"
+ "url": "https://github.com/jmeas/backbone.radio/issues"
},
Backbone events supports the, very convenient, event map syntax (allowing me to build my handler mappings in one location and bind them all in another location):
book.on({
"change:title": titleView.update,
"destroy": bookView.remove
});
But, the comply
and reply
methods do not support this. Is this by design?
I'm not entirely sold on the idea myself, but I'll try to make an argument for it since so many Backbone projects do this.
I was just looking at the built file and got thinking that putting everything in one file makes it read rather nicely. Take a minute and read through the ~270 lines of actual code:
https://github.com/jmeas/backbone.radio/blob/master/build/backbone.radio.js
I think that maybe having a bunch of source files makes the library seem larger than it really is, and maybe less approachable.
Our documentation is extensive, however I think a great many people simply read through the source in order to fully understand what the library is doing in the background.
I think it would also reason that we do things that are actually private instead of _private
. Such as _debugLog
or the upcoming _eventsApi
. Two methods that would be weird to override. The reason we don't currently do this is for jshint (which is a weak reason).
For the UMD testing, I think we can probably find another way to keep our coverage at 100%.
@jmeas What do you think?
Throw warnings if you unregister an event that was never registered to catch memleaks.
Should we?
Yup. This way I don't commit a new built lib each PR.
Right now we test that no value is returned, but I want to be complete and test that Errors aren't thrown either
We don't have any :(
We can now get the coverage report from coveralls to see the lines that we're missing.
There are 5 lines:
3 from UMD and 2 from noConflict.
This leads to two questions:
noConflict
? The only way I can think of doing it is to start a test before Backbone.radio loads...but...is that even possible?//cc @thejameskyle. I'd love to hear if you have any thoughts on this.
Response should be reply
https://github.com/jmeas/backbone.radio/blob/master/src/proxy.js#L15
return channel[methodName].apply(this, args); // this === Backbone.Radio
// should be
return channel[methodName].apply(channel, args);
We shouldn't test the UMD wrapper as that lowers coverage. Instead, we should pull in each of the files separately for the tests, instead of relying on .tmp/backbone.radio.js.
This will cause them to be instrumented separately w.o. instrumenting the UMD stuff. The only side effect will be a few additional global variables during testing, but I don't see that being an issue.
The tests work fine, but the text was a bit messed up in James' test refactor
I dislike the word 'action', as that isn't even a concept in this lib, so I'm thinking it should be commandName
for commands and requestName
for requests.
A feature request is TuneIn
; an ability to get logs of all of the events going in and out of a channel.
I've got a getting started section, but I need the entire API.
According to @thejameskyle if the tests are switched to running in a node env we will get major speed boosts. Worth looking into.
The current API is:
trigger
on, once, off
listenTo, listenToOnce, stopListening
command
react, reactOnce, stopReacting
request
respond, respondOnce, stopResponding
@thejameskyle pointed out that 'react' is not a good name for Commands' handler. I agree. What's better? Hmmm...
Doooo it. https://gitter.im/jmeas/backbone.radio
connectRequests
=> connectResponses
connectCommands
=> connectReactions
It should throw an error.
Indeed
In Backbone.Events, you can write:
evented.off('foo', myCallback, myContext);
// removes only 'foo' events that have
// `{ callback: myCallback, context: myContext }`
We should add this functionality.
Yuuuup
If a requests/commands obj has never had any handlers set, and you try to unregister a specific request, it will throw a fatal error.
Yikes.
Yup. Adding them to the README is fine for now.
@thejameskyle @ahumphreys87 maybe you two could provide some guidance on this?
You should have access to the top-level API by specifying the channel name, just like Wreqr.radio.
e.g.;
Backbone.Radio.stopListening('global');
In Backbone.Events, you can write:
evented.on('foo bar', function() {
// responds to 'foo' and 'bar'
});
We should add this functionality.
Debug mode would log to the console if you call a request or command without any handlers.
The chart showing how information is transferred between the emitter and the listener is immensely useful. It should be added here.
I'm currently working with an application that should proxy commands and requests to the server, when they are not handled by the client.
Is there a way to specifically handle only unhandled commands and requests, similar to a filtered Backbone.on('all', ...);
, so that I can bridge my local Backbone.Radio bus and Socket.IO?
You can specify the context of callbacks, but there are no tests for that behavior.
There should be a test for this.
beforeEach(function() {
this.fooStub = this.sinon.stub();
this.barStub = this.sinon.stub();
Radio.channel('foo').on('baz', this.fooStub);
Radio.channel('bar').on('baz', this.barStub);
Radio.channel('foo').trigger('baz');
});
it('should not call events on other channels.', function() {
expect(barStub).not.to.have.been.called;
});
It's lawless in there rite now
var isChannel = this.channelName ? true : false;
if (isChannel) {
// lala
}
Unnecessary code? We should check if the alternative compiles down to a smaller lib
if (this.channelName) {
// lala
}
https://github.com/jmeas/backbone.radio/blob/master/src/channel.js#L10
Looking at channels, I'm not sure if channelName
should be a public or private property. I figured it warranted a discussion.
These tests belong in the channel tests.
Small thing, but I rly don't like foo/foobar.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.