0

I have a variable like,

public categories: Observable<any[]>;

So after the service call, the returned data of service call will push an array of JSON data to the field which I mentioned above.

After that, I need to push an empty JSON data to that field. As it is a type of Observable, I can't just directly use .push

Is there any solution to push the empty JSON data to an array which is type of Observable?

Mehrdad Pedramfar
  • 10,941
  • 4
  • 38
  • 59
Chandan Y S
  • 968
  • 11
  • 21

1 Answers1

0

You just need to import latest EmptyObservable of rxjs, that will do the trick in your case.

import {EmptyObservable} from 'rxjs/observable/EmptyObservable';

public categories: Observable<any[]>;

//just assign this to your variable
this.categories = new EmptyObservable();

for more info have a look here

Ganesh
  • 5,808
  • 2
  • 21
  • 41