10. Is something
wrong in
Odoo JS
Land?
_appendController: function (controller) {
dom.append(this.$el, controller.widget.$el, {
in_DOM: this.isInDOM,
callbacks: [{widget: controller.widget}],
});
},
on_attach_callback: function () {
this.isInDOM = true;
var currentController = this.getController();
if (currentController) {
currentController.widget.on_attach_callback();
}
},
11. Or maybe
something is right
in frontend world...
<template>
<div id="app">
<h1>My Vue App</h1>
<PersonGreeter personName="Lyra" />
</div>
</template>
<script>
import PersonGreeter from
'./components/PersonGreeter.vue';
export default {
name: 'app',
components: {
PersonGreeter
}
}
</script>
Fun note: slide from last year
12. Too much work in
upper layers, not
enough at framework
level
● built-in lifecycle hooks
● declarative component system
13. So, do we pick a state of the
art/well tested, well known
framework?
Or do we make our own custom
framework?
14. ● QWeb/XML based
● monkey-patchable
● no extra tooling allowed
What we need:
15. ● works well with inheritance
● template compilation on
browser
● asynchronous rendering
Nice to have:
16. So, do we pick a state of the
art/well tested, well known
framework?
Or do we make our own custom
framework?
18. Owl Javascript Framework
● standalone framework
● declarative component system
● class based
● based on QWeb Engine
● no nonsense
https://odoo.github.io/owl/
19. Component
Example
import { Component, useState } from 'owl'
import { xml } from 'owl/tags'
class Counter extends Component {
static template = xml`
<button t-on-click="increment">
Click Me! [<t t-esc="state.value"/>]
</button>`;
state = useState({ value: 0 });
increment() {
this.state.value++;
}
}
20. import { Component } from 'owl'
import { xml } from 'owl/tags'
import { Counter } from './Counter'
class App extends Component {
static template = xml`
<div>
<span>Hello Owl</span>
<Counter t-if="state.flag"/>
</div>`;
static components = { Counter };
state = useState({ flag: true });
}
Composition