title: Set first value of BehaviorSubject in Angular
body: <p>I am pretty new into Rxjs. How can I set the first value of <code>BehaviorSubject</code> from a custom select box model who looks like this:</p>
  
  <pre><code>        private mainRangeDate: any = {beginDate: {year: 2018, month: 10, day: 9},
                                        endDate: {year: 2018, month: 10, day: 19}};
  
          constructor(public daterangeService: DaterangeService) { }
  
          ngOnInit() {
             console.log(this.mainRangeDate);
          }
  
          onDateRangeChanged(event: IMyDateRangeModel) {
             this.daterangeService.dateRangeInterval.next(event);
             console.log(event.beginDate);
          }
  </code></pre>
  
  <p>The service:</p>
  
  <pre><code>@Injectable()
  export class DaterangeService {
  
    dateRangeInterval = new BehaviorSubject&lt;Object&gt;({});
  
    constructor() { }
  
  }
  </code></pre>
  
  <p>The component template:</p>
  
  <pre><code> &lt;my-date-range-picker name="mydaterange" [options]="myDateRangePickerOptions"
                                   [(ngModel)]="mainRangeDate" (dateRangeChanged)="onDateRangeChanged($event)" required&gt;&lt;/my-date-range-picker&gt;
  </code></pre>
  
  <p>I need to set <code>BehaviorSubject</code> to be <code>mainRangeDate</code> but I don't want to make it in <code>ngOnInit</code> or using a timeout.</p>