Create a way to evaluate arbitrary javascript

Aberta
#894 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
25/100
Tipo de issue
Funcionalidade
Clareza
Precisa de esclarecimento
Status de atividade
Estagnada
Stack de tecnologia
javascript, python
Domínio
backend, frontend

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Python
Estrelas
8.1k
Forks
332
Métricas de merge de PRs
Nenhum PR com merge em 30d

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de reactive-python/reactpy

Todas as issues de reactive-python/reactpy

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.