jsonberry / rxjs-toolkit Goto Github PK
View Code? Open in Web Editor NEWRxJS Everyday Custom Operators - UNMAINTAINED
License: MIT License
RxJS Everyday Custom Operators - UNMAINTAINED
License: MIT License
I'm submitting a ...
[x] feature request
Summary
Basically do the same thing for pick
as could be done for hasProps
, see #8 for details
I'm submitting a ...
[x] feature request
Summary
It's possible that a property exists and it's value could be nullable (null
or undefined
). The developer might not want to consider a nullable value as a valid property, so if there was a strict
mode for hasProps
then it could throw
if a value checked was nullable.
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
Not sure of what the syntax would look like, here are some ideas:
source$.pipe(
hasProps('strict', 'foo', 'bar.baz'), // option 1
hasProps('foo', 'bar.baz')({strict: true}), // option 2
hasProps('strict', ['foo', 'bar.baz']), // option 3
)
Some of these could utilize TypeScript function overloads https://www.typescriptlang.org/docs/handbook/functions.html#overloads
I like the idea of option 1
because we could destructure and do some logic from there, though there's probably a better way:
export function hasProps<T>(...args: string[]) {
const [first, ...rest] = args;
const propsToCheck = first === 'strict' ? rest : [first, ...rest];
// no example of rest of the implementation here, just the idea about destructuring
return (source$: Observable<T>) =>
source$.pipe(
mergeMap((signal: T) =>
hasPropsGuard(signal, propsToCheck)
? of(signal)
: throwError(new Error(hasPropsErrorMessage))
)
);
}
I'm submitting a ...
[x ] feature request
Summary
pick
can take a period delimited string and map that to a nested property
example:
const source$ = of({
foo: 'foo',
bar: {
baz: 'baz',
}
})
source$.pipe(
pick('foo', 'baz.baz')
).subscribe(x => console.log(x)) // {foo: 'foo', baz: 'baz'}
By default the nested prop name could be the last level of the branch, so in this example baz
.
There could be an optional name for it using {[key: string]: string}
syntax:
source$.pipe(
pick('foo', {far: 'baz.baz'})
).subscribe(x => console.log(x)) // {foo: 'foo', far: 'baz'}
I'm submitting a ...
[x ] chore request
Summary
Add unit tests for pick
Get rid of that bug!!
Not sure of the correct path forward - maybe I have to bump the deps of this repo, which in hopes would bump necessary versions that are working with event-stream
I'm submitting a ...
[x] bug report
[ ] feature request
[ ] question about the decisions made in the repository
[ ] question about how to use this project
Summary
When used in an angular project using Angular @ v 6.0.1, rxjs 6.3.3, and TS at ~2.7.2, there are significant errors thrown after installing rxjs-toolkit
and the project does not load.
Forgot to grab the error when I saw it... documenting here to try and keep track of the known issue.
I'm submitting a ...
[ ] bug report
[x] feature request
[ ] question about the decisions made in the repository
[ ] question about how to use this project
Summary
Create a delayedActionCollection like this:
export function delayedActionsCollection(actionDelayTuple: ActionDelayTuple[]) {
const ret = actionDelayTuple.map(([action, delayAmount]) =>
of(action).pipe(delay(delayAmount)),
);
return concat(...ret);
}
used like this:
switchMap((d: HttpResponse<any>) =>
delayedActionsCollection([
[new fromToastActions.SuccessToast('Success!'), 2000],
[new fromToastActions.HideToast(), 5000],
[new fromMockAPIActions.ResponseSuccess(d), 0],
]),
),
import { filter } from 'rxjs/operators';
import { Observable } from 'rxjs';
export const ignoreFalsySignals = () => <T>(source$: Observable<T>) =>
source$.pipe(filter<T>(signal => !!signal));
Create this helper:
import { get } from 'lodash';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
export const propsAreTruthy = (...args: string[]) => <T>(
source$: Observable<T>,
) =>
source$.pipe(
map(signal => {
for (const arg of args) {
if (!!!get(signal, arg)) {
return false;
}
}
return signal;
}),
);
I'm submitting a ...
[x] feature request
Summary
The operators do not have return signatures, adding them will help make it more obvious to what they do in the API docs, and beyond.
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
Example:
export const pick<T, R> = (...args: string[]): Observable<R> => map((value: T) => _pick(value, args));
I'm submitting a ...
[ ] bug report
[x] feature request
[ ] question about the decisions made in the repository
[ ] question about how to use this project
Summary
Change main index to export operators only
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.