Skip to content

component should setup bindings only "afterPreviousEvents" ~8 #8

Open
@justinbmeyer

Description

@justinbmeyer

From: canjs/canjs#1591

It's possible that events are dispatched that represent changes a component's init function already knows about.

Putting this another way, in the following code:

init: function(){ 
  // draw out DOM
},
"{scope} change": function(){
  // update DOM
}

It's possible that "{scope} change" will be fired after init, but it represents a change that init already knew about.

With 2.2.3, you can work around this like:

init: function(){ 
  can.batch.afterPreviousEvents(() => {
    // draw out DOM
    this.ready = true;
  })

},
"{scope} change": function(){
  if(this.ready = true) {
    // update DOM
  }
}

Instead, can.Component could only attach bindings "afterPreviousEvents" from the perspective of init.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions