Is there a way to force structured notifications?

50 views
Skip to first unread message

Aleks Totic

unread,
Sep 15, 2015, 8:38:50 PM9/15/15
to Polymer
Sometimes, my some part of my structured data changes underneath me inside a Javascript library I can't control. The library does not tell me what the changes are, just that something did happen.

I'd like to use data binding mechanism to notify other elements about these changes. Calling this.set() does not propagate the changes, because the value is still the same. What call can I f

Concrete example:

- DataSource: js library that analyzes getUserMedia stream, and calls `callback(eventArray)` when new event happens. eventArray variable is always the same object, to which new events get appended, or old events deleted.

- Polymer({
   is: data-source-wrapper,
   properties: { events: { type: Array, notify: true } },
   start: function() {
      dataSource.listen( function(events) {
        this.events  = events; // I'd like to force event change notification here, bc does not broadcast when events === this.events
      }
   })

- <dom-module id='event-viewer'>
   <template>
    <data-source-wrapper events="{{events}}">
   <template>
 </dom-module>
Polymer( {

  observers: {
    'events.*', 'eventsChanged'
  }
})

How to I force trigger of event-viewer.eventsChanged when dataSource reports a new event?

Aleks

Aleks Totic

unread,
Sep 15, 2015, 8:42:47 PM9/15/15
to Polymer
My current workaround is to force change broadcast by setting a dummy property, which is a hack. Just being able to fire a notification would be a lot cleaner (difference between regular toilet and a washlet).

this.set('events._notify', !this.events._notify)

Reply all
Reply to author
Forward
0 new messages