孤独プログラマー譚

孤独死が近い。

2020-01-01から1年間の記事一覧

RxJS tap

前回と同じ、こちら共通関数。 function sto(x, time = 1000) { const observable = new Observable(subscriber => { setTimeout(() => { subscriber.next(x) subscriber.complete() }, time); }); return observable } function cl(x) { console.log(x) } …

RxJS mergeMap, concatMap, switchMapの違い

以下、共通関数。 function sto(x, time = 1000) { const observable = new Observable(subscriber => { setTimeout(() => { subscriber.next(x) subscriber.complete() }, time); }); return observable } function cl(x) { console.log(x) } mergeMap of(0…

Observable resolveする方法

Promiseのresolve( )に該当するのが、Observableのnext( )になる。 Observable.create((observer) => { setTimeout(() => { observer.next(1) }, 1000) }) .pipe( map(val => Number(val) + 2), map(val => Number(val) * 3), ) .subscribe(val => { console…

Angular Observable, Promiseの相互変換

ObservableもPromiseも、似たようなもんだと思ってます。 import { from as fromPromise } from 'rxjs'; const foo = this.http.get('http://localhost:3000/') console.log(foo) // Observable foo.subscribe(res => console.log(1, res)) const bar = foo.…

test

" copy file path command! -nargs=0 CopyFilePath call s:Clip(expand('%:p')) nnoremap <space>f :CopyFilePath<CR> command! -nargs=0 CopyDirPath call s:Clip(expand('%:p:h')) nnoremap <space>d :CopyDirPath<CR> command! -nargs=0 CopyCwd call s:Clip(getcwd()) nnoremap <space></space></cr></space></cr></space>…