Code Monkey home page Code Monkey logo

intersect.js's Introduction

intersect.js

Build Status

Some thin wrappers around Angular.js

Concept

This is a simple library which wraps the Angular module system to provide better injection behavior. Instead of the standard Angular way, it allows you to define a service like this:

intersect.module('example')
	.service('example.services.one', ['x', 'y', 'z'], function (x, y, z)
	{});

This is a common - but a bit redundant - pattern in Angular. Intersect can get rid of this boilerplate because the service starts with module name followed by a dot.

intersect.service('example.services.one', ['x', 'y', 'z'], function (x, y, z) {});

This might seem like a small change, but it is a bit more convenient when creating new Angular components. You don't need to keep your component construction function inside of an array any more, and defining a new component doesn't require getting a reference to the module that it was created within.

The module example is expected to already exist, and intersect will prepare the reference for you.

This library aims to maintain 100% backwards compatibility with Angular. A benefit of this goal is that (if you would like to), you can call the following function in order to patch intersect into angular itself (although this is not recommended) if necessary:

intersect.conflict();

Intersect.JS will also respond properly to being used in an AMD, CommonJS, or NodeJS environment. This means that you wont have any pesky global intersect variable sitting around if you are using a module loader.

Here's an example in CoffeeScript as well:

intersect.service 'example.services.one', [
  'example.services.x'
  'example.services.y'
  'example.services.z'

], (x, y, z) ->

Another way to organize a service in CoffeeScript could look like this:

intersect.service 'example.services.one', class
  @$inject: [
    'example.services.x'
    'example.services.y'
    'example.services.z'
  ]
  
  constructor: (x, y, z) ->

intersect.js's People

Watchers

Bailey Stoner avatar James Cloos avatar  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.