0

I have an app we have connected to Pubnub for a live socket service to keep data on the page fresh for the user.

I have an ajax call that will do something with our API, and when it is successful I call an action on the application controller. At or around the same time, as long as Pubnub is still connected it receives a message with the action handler name and it attempts to call the same action.

Ideally I want to make sure this code only runs once weather it was first called by Pubnub or by my ajax success callback. How can I do this maybe using the ember run loop? It seems viable here I'm just not able to wrap my head around how I would actually do this.

Jordan
  • 2,393
  • 4
  • 30
  • 60
  • Wont the debounce method of the run loop be suitable http://emberjs.com/api/classes/Ember.run.html#method_debounce – blessanm86 Feb 20 '16 at 06:31

1 Answers1

1

Well, I would only use the web socket.

But for your question: There is not build-in functionality in the runloop to do that. You will need some kind of uniq message id, and then have a list of processed messages and check there before you run your code.

Lux
  • 17,835
  • 5
  • 43
  • 73