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

Binding don't seem work inside a repeater #26

Closed
AsafMah opened this issue May 24, 2023 · 7 comments
Closed

Binding don't seem work inside a repeater #26

AsafMah opened this issue May 24, 2023 · 7 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@AsafMah
Copy link

AsafMah commented May 24, 2023

image

(Two way binding like inputs)

It seems that it doesn't differentiate them.

@ramedina86
Copy link
Collaborator

The documentation should be clearer, thanks for reporting this. This is expected behaviour though, as you cannot bind to context, only to state.

You can create an event handler using state and context to achieve this. There's an example here at the bottom

Thank you for trying Streamsync and providing feedback. Let me know if I can help.

@ramedina86 ramedina86 added the documentation Improvements or additions to documentation label May 24, 2023
@Capsar
Copy link

Capsar commented Jul 31, 2023

Best @ramedina86,

How does this work using a slider inside a repeater?

Binding does not work as you mentioned above, so how would a default value be set?

This is my handler function and it works:

def handle_set_chunk_size(state, context, payload):
    name = context["itemId"]
    state["loaded_documents"][name]["chunk_size"] = payload

But when initializing the repeater the slider has no value:
image

Binding it directly to for instance item.chunk_size seems more intuitive to me (no need to create such a event handler & can set default initial value).

Kind regards,
Caspar

@ramedina86 ramedina86 added the enhancement New feature or request label Jul 31, 2023
@ramedina86
Copy link
Collaborator

Hey Caspar, this is a great point -thanks for bringing it to my attention.

I'll reopen the issue. It'll be quite challenging to implement this, but worth it.

@ramedina86 ramedina86 reopened this Jul 31, 2023
@Capsar
Copy link

Capsar commented Sep 14, 2023

Hey @ramedina86,

Has a fix for this been implemented already? Or a temporary work around that you can think of?

Best regards,
Caspar

@ramedina86
Copy link
Collaborator

Hi @Capsar not yet, though it hasn't been forgotten, it'll be implemented before the end of month.

@ramedina86
Copy link
Collaborator

Hi @Capsar it's now possible (v0.2.8) to bind inside a Repeater using dynamic accessors, providing the functionality you detected was missing and some more.

For example, persons[itemId].height where itemId is the one generated by the Repeater.

This also gives you the chance to use itemId to point to a completely different dict. Although this was inspired by this issue specifically, it works outside Repeater as well.

@thondeboer
Copy link

thondeboer commented Oct 7, 2023

How is this supposed to work? Is this JUST for the binding of components to items in the repeated items.

Using your example from the docs (hint...you may want to update the docs for this use)

articles[itemId].colour

Could be bound to some dropdownselect or some other input, so a user could SET the colour to some value and it will be updated in the state for "articles"?

For display we still use

@{itemId.colour}

Could be somewhat confusing to use two separate notations, but I guess the point for this is that now you could do something like

otherstate[itemId].someattribute

and set an attribute in some other state item, here now "otherstate".

ss.init_state({
    "articles": {
        "Banana": {
            "type": "fruit",
            "colour": "yellow"
        },
        "Lettuce": {
            "type": "vegetable",
            "colour": "green"
        },
        "Spinach": {
            "type": "vegetable",
            "colour": "green"
        }
    },
    "order_list": []
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants