Coder Social home page Coder Social logo

marionette-service's Introduction

Marionette Service

Travis build status Code Climate Test Coverage

This is a library to add "Service Objects" to Marionette 2.1.x. Service Objects are an extension of Marionette.Object that allows declarative interaction with Backbone.Radio messages. Service Objects can respond to any of Radio's three message types; Events, Commands and Requests. The syntax is similar to the events syntax from Backbone Views, and looks like this:

radioEvents: {
  'app start': 'onAppStart',
  'books finish': 'onBooksFinish',
},

radioCommands: {
  'app doFoo': 'executeFoo',
},

radioRequests: {
  'resources bar': 'getBar',
},

where each hash value is in the form 'channel eventName' : 'handler'. So

radioCommands: {
  'app doFoo': 'executeFoo',
},

means that the Service will listen for the doFoo command on the app channel, and run the 'executeFoo' method. When using Radio Commands and Requests with Objects, the same rules and restrictions that normal Radio use implies also apply here: a single handler can be associated with a command or request, either through manual use of the comply or reply functions, or through the Service API.

Installation via Package Manager

npm

npm install marionette-service

bower

bower install marionette-service

Questions

Wouldn't this be a good fit for Marionette Core?

There is a PR to include this feature in Marionette v3.0.0. This library is intended as a way to use the feature in 2.1+ apps without having to wait for 3.0.

Why add a separate Service class instead of shimming the future behavior on Mn.Object?

Marionette 3.0 isn't finalized yet. APIs may change in the meantime. I don't want updating to 3.0 to break any existing service code. If the API does change I will try to track it with this library, but will do so in a semver fashion. Assuming that the API does remain stable, upgrading to the core code will consist of renaming all Service objects to Object and removing this dependency.

marionette-service's People

Contributors

benmccormick avatar paulfalgout avatar

Watchers

James Cloos avatar

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.