Subscribe
vonagam opened this issue · comments
I am writing a wrapper/helper/utility around Vest. Right now there is only one way to get notified when a suite updates - adding done
callback on a run result.
But that's covers only running and only if it is you who invoked a suite so you have access to a run result and not basic result.
I would like to give users access to a suite so that they could do resets/removals/runs but then I would not be able react to or get notified about those state changes. So the only possible solution is to either allow access through some wrapper of sorts that mirrors (and ties myself to specific version of) vest suite api and calls notifier on every mutation or to simply not give any access to a suite.
There is an internal VestBus
which already tracks what is happening with a suite. Is it possible to add method for subscription to suite state changes?
That's actually something I've had in mind for a while.
I was working (then abandoned) on a vest devtools extension that relies on that, so if you look up 2 year old branches, you'll find reference to exactly that (built upon the vest bus).
I think I can add that, but it will be a few days, since I am currently at a conference abroad.
If you want to submit a PR, feel free to do so. I'll gladly review it.
What I had in mind is:
Suite.subscribe(cb)
Cb will receive as arguments:
- Event name
- Event payload
Thinking of it again, the event payload may not even be needed in this case, and we can decide not to add it for now. It is enough to know about the event, and then you can pull whatever data you need directly from the suite. No need to expose the internals there.
the event payload may not even be needed in this case
Ye, for my use case it is not needed.
let me know if you want to take it. Otherwise, I'll implement it.
Do it. (I usually contribute when I become impatient from waiting too long for a thing that I need but you are super fast with responses and have the full picture in mind so I consider it a better choice.)
Shipped in 5.1.0. Closing.