Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>So now to the big question: is there a better way to access the router or a controller from outside Ember? Preferably send an event to either with a context.</p> </blockquote> <p>Yes. This sounds like a good fit for the ember instrumentation module. Have an appropriate controller subscribe to SignalR events, then trigger them whenever your app handles real-time notification. </p> <p>First, add a method to ApplicationController for processing updates. If not defined here the event would bubble to the router.</p> <pre><code>App.ApplicationController = Ember.Controller.extend({ count: 0, name: 'default', signalrNotificationOccured: function(context) { this.incrementProperty('count'); this.set('name', context.name); } }); </code></pre> <p>Next, setup your ApplicationController by subscribing to the <code>signalr.notificationOccured</code> event. Use the before callback to log the event and send it's payload to the controller.</p> <pre><code>App.ApplicationRoute = Ember.Route.extend({ setupController: function (controller, model) { Ember.Instrumentation.subscribe("signalr.notificationOccured", { before: function(name, timestamp, payload) { console.log('Recieved ', name, ' at ' + timestamp + ' with payload: ', payload); controller.send('signalrNotificationOccured', payload); }, after: function() {} }); } }); </code></pre> <p>Then from your SignalR Application, use <code>Ember.Instrumentation.instrument</code> to send payload to your ApplicationController as follows:</p> <pre><code>notificator.update = function (context) { Ember.Instrumentation.instrument("signalr.notificationOccured", context); }); </code></pre> <p>I posted a working copy with simulated SignalR notifications here: <a href="http://jsbin.com/iyexuf/1/edit" rel="noreferrer">http://jsbin.com/iyexuf/1/edit</a></p> <p>Docs on the instrumentation module can be found <a href="http://emberjs.com/api/classes/Ember.Instrumentation.html" rel="noreferrer">here</a>, also check out the <a href="https://github.com/emberjs/ember.js/blob/master/packages/ember-metal/tests/instrumentation_test.js" rel="noreferrer">specs</a> for more examples.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload