evg_observable 1.10.49 → 1.10.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -444,6 +444,14 @@ const menFilter = (person: Person) => person.gender === GENDER.MAN;
|
|
|
444
444
|
const womenFilter = (person: Person) => person.gender === GENDER.WOMAN;
|
|
445
445
|
const blondFilter = (person: Person) => person.hairColor === HAIR.BLOND;
|
|
446
446
|
const blackFilter = (person: Person) => person.hairColor === HAIR.BLACK;
|
|
447
|
+
const personValidationFilters = [
|
|
448
|
+
(person: Person) => !!person,
|
|
449
|
+
(person: Person) => "name" in person,
|
|
450
|
+
(person: Person) => "age" in person,
|
|
451
|
+
(person: Person) => "gender" in person,
|
|
452
|
+
(person: Person) => "major" in person,
|
|
453
|
+
(person: Person) => "hairColor" in person,
|
|
454
|
+
];
|
|
447
455
|
|
|
448
456
|
// Callback function to execute when some man is ready to work
|
|
449
457
|
const manReadyToWork = (worker: Person) => {
|
|
@@ -462,14 +470,20 @@ const blondAndBlack = (person: Person) => {
|
|
|
462
470
|
|
|
463
471
|
// Apply the filters to men$ and women$
|
|
464
472
|
men$.addFilter()
|
|
473
|
+
.pushFilters(personValidationFilters)
|
|
465
474
|
.filter(menFilter);
|
|
466
475
|
|
|
467
476
|
women$.addFilter()
|
|
477
|
+
.pushFilters(personValidationFilters)
|
|
468
478
|
.filter(womenFilter);
|
|
469
479
|
|
|
470
480
|
// Subscribe the callback function to the created Observables
|
|
471
|
-
men$.
|
|
472
|
-
|
|
481
|
+
men$.pipe()
|
|
482
|
+
.pushRefiners(personValidationFilters)
|
|
483
|
+
.subscribe(manReadyToWork);
|
|
484
|
+
women$.pipe()
|
|
485
|
+
.pushRefiners(personValidationFilters)
|
|
486
|
+
.subscribe(womanReadyToWork);
|
|
473
487
|
|
|
474
488
|
// Stream the list of people by applying the age filters
|
|
475
489
|
personal$.pipe()
|