owl icon indicating copy to clipboard operation
owl copied to clipboard

Pending promise (with KeepLast) in willUpdateProps freezes everything

Open kebeclibre opened this issue 3 years ago • 0 comments

Test on the playground with

const { Component, useState, mount } = owl;

let greeter;

class Greeter extends Component {
    constructor() {
        super(...arguments);
        greeter = this;
        this.state = useState({ word: 'Hello' });
    }
 
    willUpdateProps() {
        return new Promise(() => {});
    }
}

// Main root component
class App extends Component {
    constructor() {
        super(...arguments);
        this.state = useState({ name: 'World'});
    }
}
App.components = { Greeter };

// Application setup

async function exec() {
 app = await mount(App, { target: document.body });

app.state.lol = "iiiiiii";
greeter.state.word = "yyyyyyyyyyyy";   
}

exec()

<templates>
  <div t-name="Greeter" class="greeter" t-on-click="toggle">
    <t t-esc="props.lol"/>
    <t t-esc="state.word"/>
  </div>

  <div t-name="App">
    <Greeter name="state.name" lol="state.lol"/>
  </div>
</templates>

(Note that this happens also when willStart returns a pending promise, but in that case Greeter is not really alive and therefore cannot really decide to render itself)

Since Greeter is alive, it should be able to render itself and replace the pending rendering with its own

kebeclibre avatar Aug 27 '21 15:08 kebeclibre