How to use the map function from rxjs

Find comprehensive JavaScript rxjs.map code examples handpicked from public code repositorys.

17
18
19
20
21
22
23
24
25
26
        'python3',
        'get band names',
        [`${__dirname}/gdal/get_band_names.py`, path]
    ).pipe(
        filter(({stream}) => stream === 'stdout'),
        map(({value}) => JSON.parse(value))
    )
})

const setBandNames$ = (path, bandNames) => defer(() =>
fork icon45
star icon180
watch icon34

112
113
114
115
116
117
118
119
120
121
        request$.complete()
        log.debug(() => `${method} ${url} - ${status} (${ms}ms)`)
    }
})
return request$.pipe(
    map(response => validateResponse(response, validStatuses)),
    catchError(e => {
        if (validStatuses && validStatuses.includes(e.statusCode)) {
            return of(e)
        } else {
fork icon45
star icon178
watch icon34

57
58
59
60
61
62
63
64
65
66
log.isTrace() && log.trace(`${usernameTag(user.username)} ${urlTag(req.url)} Updating user in user store`)
firstValueFrom(
    get$(currentUserUrl, {
        headers: {[SEPAL_USER_HEADER]: JSON.stringify(user)}
    }).pipe(
        map((({body}) => JSON.parse(body))),
        switchMap(user => {
            log.isDebug() && log.debug(`${usernameTag(user.username)} ${urlTag(req.url)} Updated user in user store, connected to Google: ${!!user.googleTokens}`)
            return from(setUser(user))
        }),
fork icon45
star icon178
watch icon34

58
59
60
61
62
63
64
65
66
67
const progressState$ = task.submit$(id, params).pipe(
    distinctUntilChanged((p1, p2) => _.isEqual(
        _.pick(p1, ['defaultMessage', 'messageKey', 'messageArgs']),
        _.pick(p2, ['defaultMessage', 'messageKey', 'messageArgs'])
    )),
    map(progress => {
        if (!progress.defaultMessage || !progress.messageKey) {
            log.warn(msg(id, `Malformed progress. Must contain 'defaultMessage' and 'messageKey' properties: ${JSON.stringify(progress)}`))
            progress = {
                defaultMessage: 'Executing...',
fork icon45
star icon178
watch icon34

110
111
112
113
114
115
116
117
118
119
getInstance$: () =>
    getInstance$().pipe(
        switchMap(instance =>
            concat(of(instance), NEVER).pipe(
                tap(instance => lock(instance)),
                map(({item}) => item),
                finalize(() => release(instance))
            )
        )
    )
fork icon45
star icon178
watch icon34

+ 5 other calls in file

81
82
83
84
85
86
87
88
89
90
}

const cleanup$ = taskId => {
    log.debug(() => `EE task cleanup starting (${description}, ${taskId})`)
    return status$(taskId, 0).pipe(
        map(({state}) => isRunning(state)),
        switchMap(running =>
            running
                ? cancel$(taskId, 3).pipe(
                    map(() => true)
fork icon45
star icon178
watch icon34

+ 7 other calls in file

17
18
19
20
21
22
23
24
25
26
        retry(RETRIES)
    )
})
const download$ = ({bucketPath, prefix, downloadDir, deleteAfterDownload}) =>
    cloudStorage$().pipe(
        map(cloudStorage => cloudStorage.bucket(`gs://${bucketPath}`)),
        switchMap(bucket =>
            do$(
                `download: ${JSON.stringify({bucketPath, prefix, downloadDir, deleteAfterDownload})}`,
                bucket.getFiles({prefix, autoPaginate: true})
fork icon45
star icon178
watch icon34

+ 5 other calls in file

166
167
168
169
170
171
172
173
174
175
const selectedBands$ = selectedBands && selectedBands.length
    ? of(selectedBands)
    : imageFactory(model.reference, ccdcArgs).getBands$()

const bands$ = selectedBands$.pipe(
    map(selectedBands => ({selectedBands, baseBands}))
)
const ccdc$ = bands$.pipe(
    map(({selectedBands, baseBands}) =>
        ({
fork icon45
star icon177
watch icon0

+ 4 other calls in file

17
18
19
20
21
22
23
24
25
26
27


const apps$ = () =>
    fileToJson$('/var/lib/sepal/app-manager/apps.json').pipe(
        switchMap(({apps}) => from(apps)),
        filter(({repository}) => repository),
        map(({endpoint = 'shiny', label, repository, branch}) => {
            const name = basename(repository)
            return {
                endpoint,
                name,
fork icon45
star icon177
watch icon0

65
66
67
68
69
70
71
72
73
74
return getCollection$({
    recipe: collectionRecipe,
    geometry,
    bands: [band]
}).pipe(
    map(collection => collection.map(image => {
        var dayOfYear = image.date().getRelative('day', 'year').add(1)
        return image
            .addBands(ee.Image(dayOfYear).int16().rename('dayOfYear'))
            .set('dayOfYear', dayOfYear)
fork icon45
star icon177
watch icon0

+ 2 other calls in file

20
21
22
23
24
25
26
27
28
29
const user = req.session.user
log.debug(`[${user.username}] [${req.originalUrl}] Refreshing Google tokens for user`)
return postJson$(refreshGoogleTokensUrl, {
    headers: {'sepal-user': JSON.stringify(user)}
}).pipe(
    map(({body: googleTokens}) => {
        if (googleTokens) {
            log.debug(() => `[${user.username}] [${req.originalUrl}] Refreshed Google tokens`)
            req.session.user = {...user, googleTokens: JSON.parse(googleTokens)}
            res.set('sepal-user', JSON.stringify(req.session.user))
fork icon45
star icon0
watch icon0

+ 3 other calls in file

133
134
135
136
137
138
139
140
141
142
    )
}

const exists$ = ({path}) =>
    from(access(path)).pipe(
        map(() => true),
        catchError(() => of(false))
    )

const checkout$ = ({path, branch}) => {
fork icon45
star icon0
watch icon0

+ 5 other calls in file

54
55
56
57
58
59
60
61
62
63
log.debug(() => message)
return of(true).pipe(
    switchMap(() =>
        driveLimiter$(
            auth$().pipe(
                map(auth =>
                    google.drive({version: 'v3', auth})
                ),
                switchMap(drive =>
                    from(op(drive))
fork icon45
star icon0
watch icon0

11
12
13
14
15
16
17
18
19
20
    if (e.status === 401) {
        // throw new Error(e.statusText)
        return of(1)
            .pipe(
                tap(() => console.info('inside of')),
                map(e => {status = 200; throw new Error('trigger a retry')}),
            )
    }
    return of(e)
}),
fork icon0
star icon0
watch icon0

49
50
51
52
53
54
55
56
57
58
let cardSet = await rxjs.lastValueFrom(
  new http.HttpService()
    .get(downloadPath)
    .pipe(
      // rxjs.tap((response) => {console.log(`Request GET: ${downloadPath}`)}),
      rxjs.map((response) => response.data)
    ),
);
if (appendOnly) { // caso seja só append, adiciona o resultado no objeto
  cardSet = [
fork icon0
star icon0
watch icon0

0
1
2
3
4
5
6
7
8
9
const { interval, timer, from, of, concatMap, map, concat, take, tap, switchMap, flatMap, mergeMap, reduce, EMPTY } = require('rxjs')
// empty seems to be the Bacon.never()
interval(1000)
.pipe(
    mergeMap(e => e % 3 === 0 ? of(e) : EMPTY),
    map(e => e*2)
)
.subscribe({
    next: val => console.log('observer got val', val),
    error: err => console.error('observer errored', err),
fork icon0
star icon0
watch icon0

+ 2 other calls in file

52
53
54
55
56
57
58
59
60
61
    if (this.appintService._booking != undefined) {
        this.booking = this.appintService._booking;
        this.initializeFormData(this.booking);
    }
    this.filteredDoc = this.registrationForm.controls['doctor'].valueChanges.pipe(rxjs_1.startWith(''), rxjs_1.map(function (name) { return (name ? _this._filterDoc(name) : _this.doctors.slice()); }));
    this.filteredTown = this.registrationForm.controls['township'].valueChanges.pipe(rxjs_1.startWith(''), rxjs_1.map(function (name) { return (name ? _this._filterTown(name) : _this.towns.slice()); }));
};
//initialize form with interface model
RegistrationSetupComponent.prototype.initializeForm = function () {
    this.registrationForm = this.formBuilder.group({
fork icon0
star icon0
watch icon2

+ 61 other calls in file

41
42
43
44
45
46
47
48
49
50
AppointmentRegistrationComponent.prototype.ngOnInit = function () {
    var _this = this;
    // this.getGender();
    this.initializeForm();
    this.filteredDoc = this.appointForm.controls['doctor'].valueChanges.pipe(rxjs_1.startWith(''), rxjs_1.map(function (name) { return (name ? _this._filterDoc(name) : _this.doctors.slice()); }));
    this.filteredPatient = this.appointForm.controls['patient'].valueChanges.pipe(rxjs_1.startWith(''), rxjs_1.map(function (name) { return (name ? _this._filterPatient(name) : _this.patient.slice()); }));
};
AppointmentRegistrationComponent.prototype.initializeForm = function () {
    this.appointForm = this.fb.group({
        regNo: [null],
fork icon0
star icon0
watch icon2

+ 55 other calls in file