Giter Site home page Giter Site logo

examples's People

Contributors

bear avatar fyockm avatar henrikjoreteg avatar jarredwitt avatar jeffjewiss avatar latentflip avatar lukekarrys avatar mikehedman avatar mmacaula 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

examples's Issues

Using Ampersand with require.js

You've got an app written using AMD and require.js. You'd love to use ampersand and all its awesomeness. How do you do it?

I propose an example for those in my situation, using the solution I found useful. Basically I used browerify in my build process to process a simple proto file.

var underscoreMixin = require('ampersand-collection-underscore-mixin');
module.exports = {
    State : require('ampersand-state'),
    Registry : require('ampersand-registry'),
    View: require('ampersand-view'),
    Model: require('ampersand-model'),
    Collection : require('ampersand-rest-collection').extend(underscoreMixin)
};

I then run browserify in my gulp as a dependent task:

gulp.task('bundleAmpersand', function() {

    return gulp.src('./client/core/assets/js/libs/ampersand-proto.js')
        .pipe(plugins.browserify({
            debug : true,
            standalone : 'ampersand',
            external : ["jquery", "underscore"]
        }))
        .pipe(plugins.rename('ampersand-bundle.js'))
        .pipe(gulp.dest('./client/core/assets/js/libs'));
});

and config require.js to use ampersand in its config file:

requirejs.config({
  paths : {
// rest of config paths:
     ampersand : 'core/assets/js/libs/ampersand-bundle'
  },
  shim : {
       ampersand : ['lodash', 'jquery'],
  }
});

Then use happily:

// using nicer define vs the array type definition
define(function(require){

  var Ampersand = require('ampersand');
  var MyModel = Ampersand.Model.extend({
  /// model def
  });
  return MyModel;
});

Proposed example would flesh this out with a real project. But mostly with a heavy emphasis on the readme.md since everyone's require.js configuration is slightly different.

What's the purpose of the internals object?

Thanks for sharing these patterns. I've seen the internals object in a few hapijs projects. Is the internals object's purpose just to encapsulate application level code?

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.