Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Using T within a JS promise. #10

Closed
qroft opened this issue Mar 14, 2019 · 2 comments
Closed

Using T within a JS promise. #10

qroft opened this issue Mar 14, 2019 · 2 comments

Comments

@qroft
Copy link

qroft commented Mar 14, 2019

I am absolutely new to the JS promise solution, so please forgive me if i am missing here something. The following code just shows the first two t.js texts - the third does not appear though all Alerts (if uncommented) do work. Am i misusing the 'add' function of t.js ?

          new Promise(function(resolve, reject) {
            $('#logger').t('Starting import function.<br>',{
              beep: true,
              speed:20,
              repeat:false
            });
            setTimeout(() => resolve(1), 2000);
          }).then((result) => {
            $('#logger').t('add','Starting import function.<br>');
            //alert(result);
            return result + 2;
          }).then((result) => {
            $('#logger').t('add','Another text.<br>');
            //alert(result);
            return result + 2;
          }).then((result) => {
            $('#logger').t('add','yet antoher text.<br>');
            ///alert(result);
            return result + 2;
          });

@mntn-dev
Copy link
Owner

mntn-dev commented Mar 15, 2019

hi,

looks like t.js is still typing (check $('#logger').data().is_typing), so new to-type-content will be rejected (doesn't stack/process by default). here's a setInterval-wrapped .push/.shift-workaround:
t-stack.htm

@mntn-dev
Copy link
Owner

mntn-dev commented Mar 18, 2019

FYI
as of v1.5.4, queued type processing is now built-in --
$(elm).t('queue',content) (shorthand: $(elm).q(content) )

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants