Streaming Issue

  • jeroen4264-1305497414035312782

    Jerry

    4 months ago

    Hey! I'm trying to set up streaming but it's not working. I'm not sure if this is a problem from my backend set up (via Xano) or Toddle.

    I receive the first message instantly, and then the rest of the stream will load at once. It does come in different events.

    I've used event stream + turned off server side fetching
    1305497414374916146-image.png
    βœ…1
  • keddedev-1305533319542345799

    Kedde

    4 months ago

    Hi Jerry. I've just tried setting a simple Xano stream up too and it appears that messages do come in really fast which is fine.

    To visualize that its actually streaming I added a Sleep of 1 second in between each event in Xano.
    Another way to verify that you do actually get messages in as a stream of events is to create an event on message from the Event tab. This event will trigger every time toddle receives a message from Xano. So if you for example increment a counter variable in your component/page for each message, you can verify that you do get the expected number of messages returned by printing the counter.
  • jeroen4264-1305534069299347507

    Jerry

    4 months ago

    Yes, the sleep fixed! Thank you πŸ˜„
    πŸ™Œ1
  • jeroen4264-1305535115945967618

    Jerry

    4 months ago

    Do you perhaps know how to show paragraphs when it's streaming? I see it included \n\n but it doesn't render in Toddle
  • jeroen4264-1305535376626159656

    Jerry

    4 months ago

    this is how it shows up in Toddle and this is what it's streaming:

    ["Here","'s a 2-paragraph sentence:","\n\nAs the sun began to set behind the distant mountains, casting"," long shadows across the valley and painting the sky in"," brilliant shades of orange and purple, the ol","d farmer slowly made his way back to his weather","ed farmhouse, his boots heavy with mu","d from the day's work in the fields,"," and his faithful dog trotting contentedly beside"," him, occasionally stopping to sniff at interesting"," scents in the evening air.\n\nThe warm"," glow from the kitchen window beckoned them"," both homeward, where the farmer's wife was"," preparing a hearty stew that fille","d the air with savory aromas, an","d the promise of a peaceful evening ahea","d helped ease the aches in the farmer's tire","d muscles, while the gentle chirping of crickets provide","d a soothing soundtrack to their final"," steps toward the porch, where a"," comfortable rocking chair awaited its daily visitor","."]
    1305535376424697896-image.png
  • keddedev-1305536910738980954

    Kedde

    4 months ago

    toddle doesnt parse the content of the message and \n\n is not something that can be used as new lines in html. So you would need to manually parse it and render it correctly. A way to do that is to:
    1. use the Join-formula to join all strings in the array together
    2. Use the Split-formula on the string from 1. splitting it on "\n\n". This will create a new array where each entry is its own paragraph
    3. Use the new array in a repeat formula to render the paragraph in the correct tag on your page/component
  • keddedev-1305537877987426355

    Kedde

    4 months ago

    So it would be something like this where the first array is your data you pasted above πŸ™‚
    1305537877379256341-Screenshot_2024-11-11_at_15.20.53.png
    1305537877660401774-Screenshot_2024-11-11_at_15.20.44.png
  • And the formula in "Text" is just the "item"
  • jeroen4264-1305539839105564683

    Jerry

    4 months ago

    You the man!! Thank you so much πŸ˜„
  • jeroen4264-1305573405386342441

    Jerry

    4 months ago

    and sorry one more question πŸ˜…
    how does the copy to clipboard work

    One problem is that it now ignores all the chunks with \n\ and therefor I can't split it and also results in broken sentences. Any idea what could be wrong here?
    1305573405105328138-image.png
  • jeroen4264-1305574988111155304

    Jerry

    4 months ago

    Sorry, this is probably a Xano issue πŸ˜„
  • lucasg-1305579568815407167

    Lucas G

    4 months ago

    If you’re displaying it as an HTML block you can use the replace all node to replace \n for <br>

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code β€” but accessible to your entire team!

Try toddle β€” it's free!

Β© Copyright 2024 toddle. All rights reserved.