Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

234
Visualizações
How to send values from javascript to julia using WebIO?

I'm struggling to understand how to use WebIO. From the documentation, this would be an example to send values to javascript:

using WebIO
s = Scope()
obs = Observable(s, "logme", "")
onjs(
    s, "logme",
    js"""
    function(newValue) {
        console.log(newValue);
    }
    """
)

Now, in order to test this, I run it in the REPL followed by

using Mux
WebIO.webio_serve(
    page("/", req -> s)
)

then point my browser (Brave) to localhost:8000 and open the console (via developer tools). At this point, I expect that running obs[] = "hi there" in the REPL would make that message show up in the console. But nothing happens. Why is my understanding of the expected behavior wrong? What should I do to make the javascript console log a message that I write to an observable on the julia side?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I guess there is an error in the documentation. The problem is that there are no listeners on the observable. I.e., julia> obs returns Observable{String} with 0 listeners. You can add a listener by WebIO.ensure_sync(s, "logme"), or you can write it like this:

using Mux, WebIO, JSExpr
s = Scope()
obs = Observable(s, "logme",  "")
onjs(obs,
     js"""
     function(newValue) {
        console.log(newValue);
     }
     """
     )
webio_serve(page("/", req -> s), 8000)
obs[] = "22"

Then the web console prints out the value 22.

about 4 years ago · Juan Pablo Isaza Relatório

0

Try this It will helps

WebIO.webio_serve( page("/", req -> s) )

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda