Skip to content

Commit

Permalink
Send last event data when a widget is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
adambyrtek committed Feb 24, 2015
1 parent e18a162 commit c49e181
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions javascripts/dashing.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ class Dashing.Widget extends Batman.View
Dashing.widgets[@id] ||= []
Dashing.widgets[@id].push(@)

# In case the events from the server came before the widget was rendered
lastData = Dashing.lastEvents[@id]
if lastData
@mixin(lastData)
@onData(lastData)

type = Batman.Filters.dashize(@view)
$(@node).addClass("widget widget-#{type} #{@id}")

Expand All @@ -60,6 +54,12 @@ class Dashing.Widget extends Batman.View
@::on 'ready', ->
Dashing.Widget.fire 'ready'

# In case the events from the server came before the widget was rendered
lastData = Dashing.lastEvents[@id]
if lastData
@mixin(lastData)
@onData(lastData)

receiveData: (data) =>
@mixin(data)
@onData(data)
Expand Down

0 comments on commit c49e181

Please sign in to comment.