atom / etch

Builds components using a simple and explicit API around virtual-dom
MIT License
555 stars 57 forks source link

An unresolved update's promise when `atom.views` scheduler is used #43

Closed ivankravets closed 7 years ago

ivankravets commented 7 years ago

How to reproduce?

  async update(props) {
    await super.update(props);
    // issue: will never reach this code ...
    console.log(1);
    return Promise.resolve();
  }
nathansobo commented 7 years ago

/cc @as-cii

Maybe we can investigate this issue this week.

as-cii commented 7 years ago

Hey @ivankravets, thanks for the feedback! I have tried reproducing this issue with the following code:

etch.setScheduler(atom.views)
expect(etch.getScheduler()).toBe(atom.views)

class ParentComponent {
  constructor (props) {
    this.name = props.name
    etch.initialize(this)
  }

  update (props) {
    this.name = props.name
    return etch.update(this)
  }

  render () {
    return etch.dom.div({}, this.name)
  }
}

class ChildComponent extends ParentComponent {
  update (props) {
    return super.update(props)
  }
}

const component = new ChildComponent({name: 'A'})
expect(component.element.textContent).toBe('A')
await component.update({name: 'B'})
expect(component.element.textContent).toBe('B')

And it seems to work as expected, meaning that the promise is resolved and the assertions pass. One thing I noticed is that Babel forbids the use of the super keyword inside methods that are marked async. Maybe you are using an old version of Babel which allowed this behavior but that also contained some bug?

Could you please send us a minimal piece of code that reproduces this problem? It would help us track down what's causing it and solve it.

Thanks! ✨

ivankravets commented 7 years ago

@as-cii Antonio,

Thanks a lot for your amazing help and contributions to Atom! I had a few issues with Etch and its requirements (0.9.x requires new Atom, we can't force all users to upgrade to the latest Atom). It's very good for simple layouts. In any case, Etch is better than default Atom's "View" approach.

As result, the whole PlatformIO IDE 2.0 has been entirely rewritten in React using a new architecture that is based on React / Redux (Saga) stack.