O'Reilly logo

Ember.js Cookbook by Erik Hanchett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a chat application

In this recipe, we'll combine what you learned with initializers and dependency injection to create a chat room. The chat room will use WebSockets to communicate with the host.

How to do it...

  1. In a new application, generate these files:
    $ ember g service sockjs
    $ ember g component chat-room
    $ ember g initializer application
    $ bower install sockjs --save
    

    These will generate the files needed for the project. The chat-room component will have all the logic for the chat room that we'll create.

  2. Import the SockJS library to the application:
    // ember-cli-build.js
    …
    app.import('bower_components/sockjs/sockjs.min.js');
    …

    This will import the library so that we can use the global variable, sockjs, anywhere in our application.

  3. Create ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required