Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
IAkumaI opened this issue Jun 25, 2020 · 0 comments

Comments

@IAkumaI
Copy link
Contributor

IAkumaI commented Jun 25, 2020

  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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant