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

Explore how to duplicate a sequence #29

Closed
getify opened this issue Feb 19, 2014 · 0 comments
Closed

Explore how to duplicate a sequence #29

getify opened this issue Feb 19, 2014 · 0 comments
Assignees

Comments

@getify
Copy link
Owner

getify commented Feb 19, 2014

Given a sequence like:

var sq = ASQ(..).then(..).seq(..).val(..);

Would it be possible to duplicate a sequence, perhaps like:

var sq_template = sq.duplicate();

The duplicated sequence would probably need to start out "paused", perhaps as a mixture of iterable-sequences and normal sequences, where the first step can be externally advanced with a next() or start() or something, and the rest of the sequence would be a normal internally iterable sequence.

One way this might be useful:

// restart the sequence to recover from an error
sq.or(function recover(err){
   // swqp out to saved "backup" template
   sq = sq_template;

   // start up the new sequence
   sq.start(); // or iterable-sequence `next()`

   // now, make another "backup" template
   sq_template = sq.duplicate();

   // setup the new sequence to error recover automatically
   sq.or(recover);
});

We could perhaps even have a helper:

// restart the sequence to recover from an error
sq.or(function recover(err) {
   sq = ASQ.restart(sq_template);

   // now, make another "backup" template
   sq_template = sq.duplicate();

   // setup the new sequence to error recover automatically
   sq.or(recover);
});
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant