Giter Site home page Giter Site logo

marionettejs / backbone.radio Goto Github PK

View Code? Open in Web Editor NEW
493.0 26.0 50.0 458 KB

Messaging patterns for Backbone applications.

License: MIT License

JavaScript 98.27% HTML 1.73%
backbone marionette radio pub-sub decoupling messaging request events javascript backbone-applications

backbone.radio's People

Contributors

ahumphreys87 avatar benmccormick avatar blikblum avatar cmaher avatar codfish avatar jamesplease avatar jamiebuilds avatar jasonlaster avatar jimf avatar jonboiser avatar megawac avatar miphe avatar paulfalgout avatar pglewis avatar radkodinev avatar rafde avatar samccone avatar scott-w avatar stephanebachelier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

backbone.radio's Issues

Review return statements

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.

Quick-attach methods.

There should be handy methods to attach hashes to the messaging systems, just like we could do in Wreqr.Radio.

Use one source file?

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?

`once` methods are broken

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 :(

Remove the factory function.

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.

Command and Request does not support the event handler map syntax

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?

Use one source file?

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?

Increase coverage to 100%

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:

  1. Can we somehow get rid of the UMD thing and have it only instrument the unbuilt files?
  2. Are there clever ways to test 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.

Increase coverage to 99% by not testing UMD

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.

TuneIn functionality

A feature request is TuneIn; an ability to get logs of all of the events going in and out of a channel.

Add API docs.

I've got a getting started section, but I need the entire API.

Better name for Commands.react

The current API is:

Events

trigger
on, once, off
listenTo, listenToOnce, stopListening

Commands

command
react, reactOnce, stopReacting

Requests

request
respond, respondOnce, stopResponding

@thejameskyle pointed out that 'react' is not a good name for Commands' handler. I agree. What's better? Hmmm...

Add docs

Yup. Adding them to the README is fine for now.

Top-level API.

You should have access to the top-level API by specifying the channel name, just like Wreqr.radio.

e.g.;

Backbone.Radio.stopListening('global');

Debug mode

Debug mode would log to the console if you call a request or command without any handlers.

A generic handler for unhandled commands and requests?

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?

Add context tests

You can specify the context of callbacks, but there are no tests for that behavior.

Add test ensuring methods called on one channel don't affect others

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;
});

Consider removing isChannel pattern

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
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.