@@ -144,6 +144,10 @@ module.exports = function (public_key, config) {
144144 config . subject_filter = true
145145 }
146146
147+ if ( ! config . event_callback ) {
148+ config . event_callback = ( ) => null
149+ }
150+
147151 if ( document . querySelector ( config . element ) === null ) {
148152 config . console . error ( `SOCKET: page element "${ config . element } " does not exist, unable to start socket view.` )
149153 return
@@ -228,7 +232,7 @@ ${xhr.responseText}`)
228232 }
229233 xhr . send ( data || null )
230234 } ,
231- request_list ( url , data_property ) {
235+ request_list ( url , data_property , callback ) {
232236 this . request ( url , ( xhr ) => {
233237 let items
234238 if ( xhr . status !== 200 ) {
@@ -238,6 +242,7 @@ ${xhr.responseText}`)
238242 }
239243 data_property . splice ( 0 )
240244 items . forEach ( con => data_property . push ( con ) )
245+ callback && callback ( this )
241246 } )
242247 } ,
243248 get_contractor_list ( ) {
@@ -265,7 +270,8 @@ ${xhr.responseText}`)
265270 if ( arg_list . length > 0 ) {
266271 url += '?' + arg_list . join ( '&' )
267272 }
268- this . request_list ( url , this . contractors )
273+ const cb = ( t ) => this . config . event_callback ( 'updated_contractors' , t )
274+ this . request_list ( url , this . contractors , cb )
269275 } ,
270276 get_contractor_details ( url , link ) {
271277 if ( this . contractors_extra [ link ] !== undefined ) {
0 commit comments