-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
[BUG] Async ObservableChangeSet.Create<int, int>() does not publish changes until factory function completes. #383
Comments
I have a similar problem in a Blazor WASM app. If I change
subscribe(cache, ct); it works.
However, when
|
If you're in a position opening a PR can help Get a unit test if you can with the broken functionality |
@geometrikal good find! Removing the The I suspect it isn't 'correct' though as it is just delaying the subscription arbitrarily, and will be impacted by what happens after the method returns. We need to understand what it is that needs to occur before the subscription does, and then schedule the |
This seems to do it. return Observable.Create<IChangeSet<TObject, TKey>>(
async (observer, ct) =>
{
var cache = new SourceCache<TObject, TKey>(keySelector);
var responder = cache.Connect().SubscribeSafe(observer);
try
{
await subscribe(cache, ct);
}
catch (Exception e)
{
observer.OnError(e);
}
return new CompositeDisposable(responder, cache, Disposable.Create(observer.OnCompleted));
}); The key is to subscribe to the cache changes before awaiting the subscription. Now I need to work out how to make a proper test. |
I've checked the fix in and will deploy later today, or tomorrow. Please let me know if the issue has been correctly fixed |
* When a controller name contains "XBox", the sample application will issue a warning and not connect it, avoiding confusion. * Updated NuGet pacakges, this is particularly important as [DynamicData](https://github.com/reactivemarbles/DynamicData) has some bug fixes (notably [#383](reactivemarbles/DynamicData#383 (comment))).
I can confirm that it was broken in Honestly, this is actually quite an important fix to a major use case, congratulations! 🍾 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Describe the bug
Consider the following code using
Observable.Create
from Reactive Extensions:This is a simplification of a common use case, allowing for an on-demand triggering of an asynchronous method that produces changes over time (for example listening to a USB device, or a network port). It is particularly powerful when combined with
RefCount()
, or similar, to allow multiple subscribers to share a single connection, which is disposed (bytoken
being cancelled) when everyone stops listening.The above code produces:
The equivalent in Dynamic Data would be:
Which should have identical output to above, but instead produces:
As you can see, the subscriber is not receiving a notification, nor is
token
being cancelled directly (it appears that the factory function does stop, however, possible due to the task being terminated). The latter is less an issue astoken
cancellation is not 'guaranteed' by the Reactive Extensions specs anyway (but is a nice to have).The text was updated successfully, but these errors were encountered: