8000 fixing observable by alexandru-calinoiu · Pull Request #41 · reactiveui/refit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fixing observable #41

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

Closed

Conversation

alexandru-calinoiu
Copy link
Contributor

I am trying to fix observable,

I've added a failing test to demonstrate is not working as expected. The test is expecting OnNext to be called in 2 seconds.

For what I can figure out so far FakeAsyncSubject is not working as expected, onNext body is never executed because completion is null, OnComplete will throw and exception because final will be null.

Do you think this is a good approach shall I continue to investigate and come up with a fix?

@alexandru-calinoiu
Copy link
Contributor Author

I've also added the proposed fixes, still WIP, waiting for your commnets

@anaisbetts
Copy link
Member

I'll have a look at this soonish

@alexandru-calinoiu alexandru-calinoiu changed the title WIP fixing observable fixing observable Jun 26, 2014
@alexandru-calinoiu
Copy link
Contributor Author

The last commit deals with the fact that the methods returning Observable calling the api endpoints before any subscriptions.

This change allows to greatly simply the implementation of FaceAsyncSubject as it won't have to deal with async complications.

Inspired by https://github.com/square/retrofit/blob/master/retrofit/src/main/java/retrofit/RxSupport.java

@alexandru-calinoiu alexandru-calinoiu mentioned this pull request Jun 28, 2014
@@ -36,6 +36,9 @@
<Reference Include="Castle.Core">
<HintPath>..\ext\Net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Moq">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nooooooope. Using Moq to test Rx is a recipe to write bad tests because it's really hard to correctly mock Rx behavior, just use Rx in the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will add a poco MockObserver and use that, just to get this merged.

I do not agree with your statement, if you look at the test, Moq makes perfect sens in this context. I do agree with the fact that overusing mocks is a bad thing, I try to avoid it at all costs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Balauru You probably want Observer.Create

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flagbug I don't think so, I will have to do some assertions and we don't have the rx library included, we can only depend on the System.IObserver

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can totally add rx-main and rx-testing to the tests (and should!).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've update the tests and removed Moq

@anaisbetts
Copy link
Member

This change allows to greatly simplify the implementation of FaceAsyncSubject as it won't have to deal with async complications.

So, this change changes the semantics of how Observable methods work in Refit:

  • Before: The network request is initiated once when the method is called, and replayed whenever a new person subscribes. This is the behavior of AsyncSubject.
  • After: The Observable returned is Cold, and each subscription causes a new network request to be issued.

While I'd perhaps argue that we should switch to After, we're definitely changing the existing behavior, which means we should save that for Refit 2.0

@alexandru-calinoiu
Copy link
Contributor Author

The first 3 commits, deal with the Before functionality, that was not working, I've written failing unit tests for it.

Only the last commit changes the functionality.

Since it was not working in the first place, I doubt there was someone using it and thus it does not make sens to delay it until version 2.0.

@anaisbetts
Copy link
Member

Hey @Balauru, thanks for hacking on this - I fixed it a different way, but it should definitely work now. I'm going to stick with the AsyncSubject-based approach for now but I might change this in 2.0

@anaisbetts anaisbetts closed this Jul 6, 2014
@alexandru-calinoiu
Copy link
Contributor Author

I am not giving up :), I've send a new pull request that does not break backward compatibility https://github.com/paulcbetts/refit/pull/50

@alexandru-calinoiu alexandru-calinoiu deleted the observable branch March 9, 2015 08:48
@lock lock bot locked and limited conversation to collaborators Jun 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0