Skip to content

How to deal with dynamic strings #595

@okboy5555

Description

@okboy5555

Description

I am implementing an AI dialogue function, strings,i need to dynamically change the value of strings,since my data is being streamed, it may need to change while typing.
After 2 days of trying,I found that it seems that such a function cannot be achieved.

const typed = new Typed(dialogueContentRef.current, {
      strings: dialogueContentRef.current.strings,
      typeSpeed: 50,
      showCursor: false,
    });
    dialogueContentRef.current.typed = typed;

when i try to change strings value

dialogueContentRef.current.strings.push(messageValue)  // it can't work
dialogueContentRef.current.strings = ['test']  // it can work

Now, not providing a way to continue typing, I have to reset, like this

dialogueContentRef.current..reset()

The problem with this is that all the text is printed from scratch, which doesn't satisfy my expectations.
I hope that when I receive new text, I can continue to print
like this

this demo shows print 'test1', after xxx s, print 'test2'

print('test1');
settimeOut(xxx);
print('test2');
settimeOut(xxx);
print('test3');
.
.
.

Do you have any good suggestions, because currently it seems that strings cannot be accepted with a state

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions