ngxtension / ngxtension-platform

Utilities for Angular
https://ngxtension.netlify.app/
MIT License
626 stars 88 forks source link

RxJs Operator: stateful() #462

Open michaelbe812 opened 4 months ago

michaelbe812 commented 4 months ago

Hi, I would like to contribute an RxJs Operator which will take a underlying (async) source and emits some stateful values.

Example

http = inject(http)

// will emit: 
// {value: undefined, error:undefined, isLoading:true}
// {value: T, error:undefined, isLoading:false}
data$ = this.http.get(...).pipe(
  stateful()
)

This can also be combined with the derivedLoading-operator/behavior I contributed recently

ajitzero commented 4 months ago

See #56 for original ask and discussion. #354 is similar too, with a slightly different usage API.

For some of my projects, I maintain a custom RxJs operator for this but would love to have something more standard.

michaelbe812 commented 4 months ago

I see. As far as I can see there's so far no conclusion if this feature should be implemented?