Reputation: 14563
New to CycleJS, I'm trying to read some data from an HTTP driver, and write to it when the user makes changes. I have the following:
An initial request is just a simple GET.
const initialRequest$ = Observable.just({url: ...});
Based on some captured user intent, I update my model and create (or try to create at least) a PATCH request to update the remote data.
const patchRequests$ = intent$
.withLatestFrom(model$, (intent, model) => {
const payload = ... // get payload from model and intent
return {
url: `my/url/${target}`,
method: 'PATCH',
send: {
// payload...
},
};
});
Then I merge the streams together with:
const request$ = Observable.merge(initialRequest$, patchRequests$);
and return request$
to the HTTP driver.
My initial request goes through just fine and I get the data in the HTTP source stream. But the patches never fire.
I can subscribe to the request$
with something like:
request$.subscribe((req) => console.log(req));
And I'll see my initial request and patch requests all logged to the console. But still the patch requests are never sent.
What am I doing wrong here?
Thanks.
Upvotes: 2
Views: 112
Reputation: 13994
Give eager: true
as one of the properties of the request object. Otherwise, the HTTP Driver ignores requests that don't have a corresponding response$ waiting for it in the application.
This will change in a future version of Cycle.js, though, all requests will be eager and you wouldn't see this problem.
Upvotes: 3