Skip to content
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

Observable got called twice #3

Open
qiluo opened this issue Jun 29, 2017 · 1 comment
Open

Observable got called twice #3

qiluo opened this issue Jun 29, 2017 · 1 comment

Comments

@qiluo
Copy link

qiluo commented Jun 29, 2017

addTodo(newTodo:Todo):Observable {

        let obs = this.todoBackendService.saveTodo(newTodo);

        obs.subscribe(
                res => {
                    this._todos.next(this._todos.getValue().push(newTodo));
                });

        return obs;
}

obs would get called twice, since there are two subscribers (inner and outer of addTodo method), may have to change it to let obs = this.todoBackendService.saveTodo(newTodo).share();

@markonyango
Copy link

Just out of curiosity, why does one need an observable here at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants