title: Typescript Angular - Observable: how to change its value?
body: <p>Maybe I'm missing something. I can't find a simple tutorial for Observable and its syntax. I'm working with Angular, I need to call a function (defined in a component) from a service. I read this <a href="https://stackoverflow.com/questions/36309837/angular-2-service-call-function-in-component">solution</a>. But I can't figure out how to change the value in the Observable created in the service (maybe the creation is not the best method).</p>
  
  <p>I have a component like in the solution:</p>
  
  <pre><code>@Component({
    selector: 'my-component',
    ...
  )}
  export class MyComponent {
     constructor(myService:MyService) {
     myService.condition.subscribe(value =&gt; doSomething(value));
  }
  
  doSomething(value) {
    if (value) // do stuff
    else // other stuff
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and this is my service:</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { Observable} from 'rxjs/Observable';
  
  @Injectable()
  
  export class MyService {
      private condition: Observable&lt;boolean&gt;;
      constructor() { 
         this.condition= new Observable(ob =&gt; {ob.next(false); })
         // maybe ob.next is not the best solution to assign the value?
      }
  
      change() {// how can i change the value of condition to 'true', to call
                // the doSomething function in the component?? 
      }
  
  }
  </code></pre>