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

Feature request: connect command returns a Promise #114

Open
olzzon opened this issue Sep 3, 2018 · 4 comments
Open

Feature request: connect command returns a Promise #114

olzzon opened this issue Sep 3, 2018 · 4 comments
Assignees

Comments

@olzzon
Copy link
Contributor

olzzon commented Sep 3, 2018

I don´t know if it´s a hard one to implement.

But when initialising a CG connection with autoConnect: false
It would be great to have a promise when calling .connect()
so I could do a

connection.connect()
.then( setState......... etc.

Hope it makes sense :)

@olzzon
Copy link
Contributor Author

olzzon commented Sep 3, 2018

If not I will find some function that gives a promise and use that. :)

@jesperstarkar
Copy link
Member

This TOTALLY makes sense. This was my first project with promises, and my first library project. Would love to rewrite major parts of it.

@jesperstarkar jesperstarkar self-assigned this Sep 3, 2018
@mint-dewit
Copy link
Contributor

Quick fix you can use for now if you want:

connect () {
	return new Promise((resolve, reject) => {
		const timeout = setTimeout(() => reject(), 10000)

		CasparCG.connect()
		CasparCG.once('connected', () => {
			clearTimeout(timeout)
			resolve()
		})
	})
}

@olzzon
Copy link
Contributor Author

olzzon commented Sep 3, 2018

I just put the promise to another command and did this:

connection.connect()
connection.stop(1, 10)
.then(
..........

:)

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

No branches or pull requests

3 participants