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

_mutate_xxx‘s bug or for some other reason #743

Closed
1751660300 opened this issue Dec 20, 2023 · 2 comments
Closed

_mutate_xxx‘s bug or for some other reason #743

1751660300 opened this issue Dec 20, 2023 · 2 comments

Comments

@1751660300
Copy link

1751660300 commented Dec 20, 2023

hello,
I want to update the ListProp and print its value, but the console outputs the initial value instead of the updated value for the first time. Is he a bug or for some other reason?

The result is :
JS:
JS: D,E,F

my code:

from flexx import flx

class Test(flx.Widget):
    str_list = flx.ListProp(settable=True)

    def init(self):
        self.btn = flx.Button(text='测试')

    @flx.action
    def replace_str_list(self, items):
        # 替换值
        self._mutate_str_list(items, 'set')

    @flx.reaction('btn.pointer_click')
    def main(self, *events):
        self.replace_str_list(['D', 'E', 'F'])
        print(self.str_list)
@almarklein
Copy link
Member

Do you mean that on the first click the result is [], and only on the second click it shows the updated value?

In the docs (https://flexx.readthedocs.io/en/stable/event/api.html#actions) it says:

Actions are asynchronous and thread-safe. Invoking an action will not apply the changes directly; the action is queued and handled at a later time. The one exception is that when an action is invoked from anoher action, it is handled directly.

@1751660300
Copy link
Author

OK,thanks。

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

2 participants