X Tutup
Skip to content

Http requests should be lazy / cold Observables #4043

@robwormald

Description

@robwormald

As Http is Observable powered, it makes more semantic sense for requests to be "lazy", that is, nothing should happen until .subscribe is called somewhere downrange.

Currently, calling http.get(url) will immediately fire off an XHR, irrespective of whether or not the request has been subscribed to. This is probably a side-effect of the EventEmitter using a Subject (and thus could be resolved when RxNext goes in) - generally we should opt for Observables for such things and only use Subjects when necessary.

See http://plnkr.co/edit/ncg5Kx?p=preview for a reproduction / naive semantically better implementation.

Suggested fix would be having backends etc initialize and return an Observable that could be .mapped to the Response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    X Tutup