Observable creators (eg static operators)
- Cheat sheet Don't make these 7 mistakes we made when we started with ngx-translate! Learn more in our newsletter and get our free ngx-translate cheat-sheet: All you need to know on a single page.
- A-rxjs-import: import RxJs features: a-rxjs-operators: import RxJs operators: a-route-path-404: 404 route path: a-route-path-default: default route path: a-route-path-with-children: route path with children: a-route-path-eager: eager route path: a-route-path-lazy: lazy route path: a-router-events: listen to one or more router events: a-route.
Angular 9 and Angular 10 Development Cheat Sheet Using NgRx Store with Angular Building Single Page Applications (SPA) with Angular Router Unit Testing Angular Components Angular Evolution - Version 1.x to 6 Ahead of Time Compilation - AoT in Angular (Performance Improvements).
of
immediately emit all arguments provided
from
convert a promise or array or iterable or Observable-like object to Observable
or
interval
create
merge
more Creation Operators: http://reactivex.io/rxjs/manual/overview.html#creation-operators
Observable operators: Persistence
scan
Observable operators: Flow control
throttleTime
filter
delay
debounceTime
take
takeUntil
distinct
distinctUntilChanged
Observable operators: Pure Transforms
map
pluck
pairwise
sample
An observable that returns both synchronously AND asynchronously
Subscribe/Unsubscribe interface implemented in pure javascript (no rxjs)
So why use rxjs if it can be done in pure js? “The reason why we use Rx types like Observable, Observer, and Subscription is to get safety (such as the Observable Contract) and composability with Operators.”
adding/removing Child subscriptions
As a developer in the .NET world where LINQ is first class citizen, when going to JavaScript it seems that some methods are missing. There is even afew libraries that tries to remedy this, but if you are just looking to get the job done the most often used methods are right at hand. (Looking for features such as Lazy-evaluation or observables, linq.js and RxJS offers these).
In the following I’ll list the most used operations and their JavaScript equivalents cheat sheet style. Notice that I’m using Lambda expressions in JavaScript to get the code a bit more concise, if they aren’t available just replace expressions like:
with
All operations are executed against this example:
Notice that some of the operations modifies the source array, if you don’t want that just clone it with:
Every operation is named after the method’s name in LINQ:
AllRxjs Examples
ForEachSo clearly you don’t need a library if you only need the basic operations. The code above with tests is available at GitHub.
Rxjs Cheat Sheet 2019
This post is also available in Danish at QED.dk.
Rxjs Cheat Sheet 2020
Rxjs Cheat Sheet Pdf
[…] This post is also available in English at Complexitymaze.com. […]
You should use [].every instead of the unnecessary [].filter combined with [].length when doing the LINQ equivalent of .All()
persons.every(person => person.type ‘Person’)
@Kevin Reed, I did not know about every(). Thanks for the feedback
Did not know about Array.prototype.every as well. Cheers Kevin.
You can use JavaScriptLinq http://www.javascriptlinq.com/ It havs all linq functions
persons.Any(p=>p.Type “person”)
persons.some(p=>p.type “person”)Here is one missing function
Select
C#
var result = persons.Select(person => new {fullname = person.firstname + ” ” + person.lastname});JavaScript
var result = persons.Select(function(person) {return {fullname = person.firstname + ” ” + person.lastname});