Coder Social home page Coder Social logo

Comments (4)

ramedina86 avatar ramedina86 commented on July 30, 2024 1

Hi Mikita, as discussed earlier let's treat this as a potential enhancement. As discussed here, mutation detection happens by assignment and List is no exception.

from streamsync.

FabienArcellier avatar FabienArcellier commented on July 30, 2024 1

@mmikita95 I think this one has been delivered in 0.4.0. Could you confirm ?

from streamsync.

ramedina86 avatar ramedina86 commented on July 30, 2024

@raaymax wants to fix this :)

from streamsync.

mmikita95 avatar mmikita95 commented on July 30, 2024

@FabienArcellier sadly, can't confirm. Good news is that the state keeps this change – I think I remember that it was not the case, but the change still doesn't get propagated to the frontend instantly – it has to "wait" on another, "trackable" change.

This is the setup I used to test if you're interested:
main.py

import streamsync as ss

def implicit_list_modification(state):
    state["list_to_be_modified"].append("test")

def explicit_list_modification(state):
    state["list_to_be_modified"] += ["test"]

initial_state = ss.init_state({"list_to_be_modified": []})

ui.json

{
    "metadata": {
        "streamsync_version": "0.4.0"
    },
    "components": {
        "root": {
            "id": "root",
            "type": "root",
            "content": {
                "appName": "List modification test"
            },
            "isCodeManaged": false,
            "position": 0
        },
        "main-page": {
            "id": "main-page",
            "type": "page",
            "content": {
                "pageMode": "",
                "key": "main"
            },
            "isCodeManaged": false,
            "position": 0,
            "parentId": "root"
        },
        "d2w3obvhbri2sbut": {
            "id": "d2w3obvhbri2sbut",
            "type": "columns",
            "content": {},
            "isCodeManaged": false,
            "position": 0,
            "parentId": "f2qst53hgdfydwyw",
            "handlers": {},
            "visible": true
        },
        "437w7haqfmf98fx7": {
            "id": "437w7haqfmf98fx7",
            "type": "column",
            "content": {
                "width": "1"
            },
            "isCodeManaged": false,
            "position": 0,
            "parentId": "d2w3obvhbri2sbut",
            "handlers": {},
            "visible": true
        },
        "3qqlvgpygldtm3zu": {
            "id": "3qqlvgpygldtm3zu",
            "type": "column",
            "content": {
                "width": "1"
            },
            "isCodeManaged": false,
            "position": 1,
            "parentId": "d2w3obvhbri2sbut",
            "handlers": {},
            "visible": true
        },
        "f2kq09lfygpmx8ot": {
            "id": "f2kq09lfygpmx8ot",
            "type": "button",
            "content": {
                "text": "Test implicit list modification"
            },
            "isCodeManaged": false,
            "position": 0,
            "parentId": "437w7haqfmf98fx7",
            "handlers": {
                "ss-click": "implicit_list_modification"
            },
            "visible": true
        },
        "pz9w7yngw9o4iqxz": {
            "id": "pz9w7yngw9o4iqxz",
            "type": "text",
            "content": {
                "text": "@{list_to_be_modified}"
            },
            "isCodeManaged": false,
            "position": 0,
            "parentId": "3qqlvgpygldtm3zu",
            "handlers": {},
            "visible": true
        },
        "uzp2y2hlnsfyck32": {
            "id": "uzp2y2hlnsfyck32",
            "type": "button",
            "content": {
                "text": "Test explicit list modification"
            },
            "isCodeManaged": false,
            "position": 1,
            "parentId": "437w7haqfmf98fx7",
            "handlers": {
                "ss-click": "explicit_list_modification"
            },
            "visible": true
        },
        "f2qst53hgdfydwyw": {
            "id": "f2qst53hgdfydwyw",
            "type": "section",
            "content": {
                "title": ""
            },
            "isCodeManaged": false,
            "position": 0,
            "parentId": "main-page",
            "handlers": {},
            "visible": true
        }
    }
}

Expected effect is that "test" appears in the list on button press for both cases – but, in fact, the "test"s appended by the click(s) of the first button only appear when the second, "explicit" button is pressed.

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.