Create a way to evaluate arbitrary javascript

Offen
#894 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
25/100
Issue-Typ
Feature
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
javascript, python
Bereich
backend, frontend

Rechercherichtung

Start by reading the existing html.script and Django use_query hooks, then review the traceability comment in issue 857. Define how use_script should return JavaScript results, support asynchronous or deferred event execution, and handle the this keyword. Done means the proposed examples have a clear, working interface.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

priority-3-low type-investigation
Current Situation

Currently, there is no method to transmit the results of a JavaScript function to the backend.

Proposed Actions

This might look like a use_script hook that operates similarly to html.script, but can return a result.

For example,

@component
def example():
    executor = use_script("getComputedStyle(document.querySelector('#element'))")
    return f"CSS Style Attributes: {executor.data}"

Since this hook would need to operate asynchronously, the interface would likely be heavily inspired by our Django use_query hook.

And perhaps it could be used as an executor within event contexts to be more "reactive":

@component
def example():
    executor = use_script("getComputedStyle(document.querySelector('#element'))", deferred=True)

    async def on_click(event):
        await executor()
        example_value = executor.data 

    return f"CSS Style Attributes: {script.data}"

See this comment for traceability.

Note: If possible, we should try pre-populate this keyword with something that makes sense, depending on where the JavaScript was executed.

Vorherrschende Sprache
Python
Sterne
8.1k
Forks
332
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus reactive-python/reactpy

Alle Issues in reactive-python/reactpy

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.