Coder Social home page Coder Social logo

Comments (7)

Capsar avatar Capsar commented on September 28, 2024 1

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

from streamsync.

ramedina86 avatar ramedina86 commented on September 28, 2024

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.

from streamsync.

ramedina86 avatar ramedina86 commented on September 28, 2024

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.

from streamsync.

Capsar avatar Capsar commented on September 28, 2024

Hey @ramedina86,

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

Best regards,
Caspar

from streamsync.

ramedina86 avatar ramedina86 commented on September 28, 2024

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

from streamsync.

ramedina86 avatar ramedina86 commented on September 28, 2024

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.

from streamsync.

thondeboer avatar thondeboer commented on September 28, 2024

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": []
})

from streamsync.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.