Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to close demo after "end( )" ? #47

Closed
guifelix opened this issue Dec 30, 2018 · 7 comments
Closed

How to close demo after "end( )" ? #47

guifelix opened this issue Dec 30, 2018 · 7 comments
Labels
enhancement New feature or request
Projects

Comments

@guifelix
Copy link

It should have a "close( )" method to close the terminal after ending.

@rafaelcamargo rafaelcamargo added the enhancement New feature or request label Jan 1, 2019
@rafaelcamargo
Copy link
Member

A previous PR seems to be related to this. Investigate the best approach to handle this issue.

@rafaelcamargo rafaelcamargo added this to Not Planned in Roadmap Jan 1, 2019
@guifelix
Copy link
Author

guifelix commented Jan 7, 2019

I don't know if I understood it right, but this PR is about returning a promise, right? But nothing about closing the terminal after "end()". If I'm mistaken please disregard this comment

@rafaelcamargo
Copy link
Member

🤔
I was wondering that returning a promise you could do something like:

gdemo.openApp('terminal').command('node demo.js').end().then(() => {
  // here you can make anything, including an animation to simulate terminal close.
});

However, you might be meaning:

gdemo.openApp('terminal').command('node demo.js').closeApp('terminal').end();

Is this (closeApp) what you mean?

@guifelix
Copy link
Author

guifelix commented Jan 8, 2019

Now that you've mentioned... I can see purpose on both approaches!

here is what I'm trying to do:

new Promise((resolve, reject) => {
            new GDemo('#shell').openApp('terminal', {minHeight: '350px', promptString: '$'})
                .command('google-chrome index.html', {onCompleteDelay: 1500})
                .respond('Opening in existing browser session.')
                // .command('clear', {onCompleteDelay: 1500})
                .command('')
                .end();
            setTimeout(() => resolve("done!"), 6500);
        })
        .then(() => {
            // Trying to simulate terminal "clear"
            // $('#shell > div > div > div > div.application-content-container > div:nth-child(1)').remove();
            // $('#shell > div > div > div > div.application-content-container > div:nth-child(2)').remove();
            // $('#shell > div > div > div > div.application-content-container > div:nth-child(3)').remove();
            // Some logic here
            var currentLine = $('.cursor-active');

            var options = {
                strings: ["Some string to be typed inside GDemo with this other lib (https://mattboldt.com/demos/typed-js/)"],
                typeSpeed: 40,
                startDelay: 200
            }

            $(currentLine).addClass('cursor');
            var typed = new Typed(".cursor-active", options);
            $(currentLine).removeClass('cursor-active');

        })
        .then(() => {
            GDemo('#shell').closeApp()
        });

@rafaelcamargo
Copy link
Member

I think I got it now. To do this, three improvements would be actually need:

1 - .end() should return a promise
2 - A new method to close applications should be created .closeApp(appName)
3 - A new method to clear terminal applications should be created .clear()

Doing so, your code will be something like that:

const demo = new GDemo('#shell');

demo.openApp('terminal', {minHeight: '350px', promptString: '$'})
  .command('google-chrome index.html', {onCompleteDelay: 1500})
  .respond('Opening in existing browser session.')
  .command('clear', {onCompleteDelay: 1500})
  .clear()
  .command('')
  .end()
  .then(() => {
    return new Promise((resolve, reject) => {
      // Do the stuff with third party lib
    })
  })
  .then(() => {
    demo.closeApp('terminal').end();
  });

Is it right?

@guifelix
Copy link
Author

guifelix commented Jan 8, 2019

Yeah, pretty much it!

@rafaelcamargo
Copy link
Member

Split in the following issues:

Roadmap automation moved this from Not Planned to Done Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Roadmap
  
Done
Development

No branches or pull requests

2 participants