Create a way to evaluate arbitrary javascript

Aperta
#894 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
javascript, python
Ambito
backend, frontend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
8.1k
Fork
332
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di reactive-python/reactpy

Tutte le issue di reactive-python/reactpy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.