Skip to content

[Bug] Derby tries to rewrite model with external bindings when templates updated in dev mode #584

@IAkumaI

Description

@IAkumaI
  1. I have a component with search-by-query. Something like this:
<input value="{{ query }}" />
import {Component} from 'derby';

export class UserSearchForm extends Component {
    static readonly is = 'user-search-form';
    static readonly view = __dirname;

    create() {
        this.model.on('all', 'query', () => {
            this.onSearch();
        });

        this.onSearch();
    }

    onSearch() {
        // Omitting unsubscribe old query and other stuff. It does no matter, i tested
        let $query = this.model.root.query('user', {some: this.model.get('query')});
        $query.subscribe(() => {
                this.model.ref('users', $query); // Important to create ref to reproduce the bug
        });
    }
}
  1. And page template. Important to create binding with name as-ref (users) and bing it to __page
<view is="user-search-form" users="{{ _page.users }}" />
{{each _page.users as #user}}
{{ #user.id }}<br/>
{{/each}}
  1. Now run and make some searches - it works. Then change index.html template (let add some symbol) in dev mode with live-update. And search again. And change template and search again and etc.

After several iterates derby will try to write to users, but there is no sets in code.
I guess this is because it tries to rewrite old items in _page.users with new search results ot someting like this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions