Skip to content

Commit

Permalink
Merge pull request #21 from ngbox/fix/options-not-passed
Browse files Browse the repository at this point in the history
Passed options given to ObserveFn to value and collection methods
  • Loading branch information
mehmet-erim authored May 2, 2021
2 parents 838fad4 + eac07a9 commit 5b5b7d0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions projects/ng-observe/src/lib/ng-observe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ export const OBSERVE_PROVIDER = [

export function observeFactory(service: ObserveService): ObserveFn {
return <ValueOrCollection extends any>(
source: Observable<ValueOrCollection> | ObservableCollection<ValueOrCollection>
) => (isObservable(source) ? service.value(source) : service.collection(source));
source: Observable<ValueOrCollection> | ObservableCollection<ValueOrCollection>,
options?: ObserveValueOptions | ObserveCollectionOptions<ValueOrCollection>
) =>
isObservable(source)
? service.value(source, options as ObserveValueOptions)
: service.collection(source, options as ObserveCollectionOptions<ValueOrCollection>);
}

type ObserveCollectionFn = <Collection>(
Expand Down Expand Up @@ -136,7 +140,7 @@ export type ObservableCollection<Collection> = Collection extends Array<infer Va
export type ObserveCollectionOptions<Collection> = Collection extends Array<any>
? Array<ObserveValueOptions>
: {
[Key in keyof Collection]: ObserveValueOptions;
[Key in keyof Collection]?: ObserveValueOptions;
};

export type ObservedValues<Collection> = Collection extends Array<infer Value>
Expand Down

0 comments on commit 5b5b7d0

Please sign in to comment.