feat: map operator correction
This commit is contained in:
parent
346bbd851a
commit
44f4a97b95
@ -2,7 +2,22 @@ import { Observable } from '../Observable';
|
||||
import { OperatorFunction } from './types';
|
||||
|
||||
export function map<T, R>(project: (value: T) => R): OperatorFunction<T, R> {
|
||||
void Observable;
|
||||
void project;
|
||||
throw new Error('TODO');
|
||||
return source => {
|
||||
return new Observable(observer => {
|
||||
const next = (value: T) => {
|
||||
try {
|
||||
const result = project(value);
|
||||
observer.next(result);
|
||||
} catch (e) {
|
||||
observer.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
return source.subscribe({
|
||||
next,
|
||||
error: err => observer.error(err),
|
||||
complete: () => observer.complete(),
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user