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

searchStream #40

Open
mikevercoelen opened this issue May 18, 2019 · 3 comments
Open

searchStream #40

mikevercoelen opened this issue May 18, 2019 · 3 comments

Comments

@mikevercoelen
Copy link

Instead of waiting for a timeout, search results could appear in a stream / event bus.

Is this something that would be possible? I would love to put in the work, but I have no idea where to start, if someone can give me pointers and advise if this is possible or not, that would be very helpful.

Thanks

@f-hj
Copy link
Owner

f-hj commented May 23, 2019

Hi,
I think that you can use https://github.com/f-hj/slsk-client#events to get results while you're receiving it

@mikevercoelen
Copy link
Author

The ideal interface would be a stream.

How it works currently is: you search, until the timeout.

What about if you have a UI where you search infinite till the user want's it to stop?

If we use streams we could just stop it, and use on.data to handle events. Makes more sense to me

@carcabot
Copy link

carcabot commented Jun 14, 2019

Hi @mikevercoelen ,

There must be a timeout to prevent loading too much memory.

I think it's enough to use event function, it helps you to use results before search is finished.

// connect
// ....
client.search({
    req: 'random',
    timeout: 5000 // you can increase if you want a deeper search
}, (err, res) => {
    if (err) return console.log(err)

})
// use event function
client.on('found', function(result) {
    console.log(result)
    // you will get result in real time
});

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