Currently, I'm working on writing TypeScript code for a component. Within this TypeScript class, I have created a function that is meant to return a number representing the length of an array. My goal is to have this function work like an Observable. However, I encountered an error stating "number is not assignable to type Observable."
NumItemsCart():Observable<number>{
let string_items = '';
let array_temp = [];
let num_items=0;
string_items = localStorage.getItem('ecmm_list_shopcart');
array_temp= cadena_items.split(',')
num_items= array_temp.length -1
return num_items
}