widgetti / ipyvue

Jupyter widgets base for Vue libraries
MIT License
68 stars 18 forks source link

feat: allow a vue template to have a data function #62

Closed maartenbreddels closed 1 year ago

maartenbreddels commented 1 year ago

So we can do

<script>
module.exports = {
    data: () => ({
        items: [],
    }),
    created() {
        this.items = [];
    },
...

data needs to be a function because we can create multiple models out of a single template, but with different data.

maartenbreddels commented 1 year ago

@mariobuikhuizen noted that the state of these data values have a different life cycled compared to the widget, if hot reloading it used. Hot reloading will use the current values of the widget model, but the data will be reset.