5月メモ・リンク集
5 月に調べたことのメモです。
Angular 関連
third party lib
- stories global scripts · angular/angular-cli Wiki · GitHub
- 例えばグローバルに jQuery を
- import はしてはいけない
Once you import a library via the scripts array, you should not import it via a import statement in your TypeScript code (e.g.
import * as $ from 'jquery';
). If you do that you'll end up with two different copies of the library: one imported as a global library, and one imported as a module.
- stories third party lib · angular/angular-cli Wiki · GitHub
tsconfig.app.json
のtypes
に追加
Testing in ngrx
// error expect(action).toEqual({ type: LOAD_PIZZAS }); // => Expected object to be a kind of Object, but was LoadPizzas({ type: '[Products] Load Pizzas' }) // もうちょい expect(action.type).toEqual(LOAD_PIZZAS); // good expect({ ...action }).toEqual({ type: LOAD_PIZZAS });
Reducers play a few key roles for us:
- Accept old state, and an action
- Respond to actions and compose/return new state
- Handle changes via immutable patterns ... To go with it, my reducer - which uses an entity pattern to flatten my data structure into object keys for performance:
Version 6
- Angular Update Guide
- ng update @angular/core fails · Issue #10621 · angular/angular-cli · GitHub
- Version 6 of Angular Now Available – Angular Blog
Rx 関連
- RxJS: Avoiding takeUntil Leaks – Angular In Depth
- takeUntil の利用(タイミング)に気をつけないと unsub されない場合があるので気をつけましょうという記事
- rx-avoiding-takeuntil-leaks - StackBlitz
- 自分で用意したデモ
catchError
- catch しても stream は終了する
- javascript - RxJs catch error and continue - Stack Overflow
- Continue RxJS Streams When Errors Occur: The Quest for Meatballs
If an error is thrown within an operator, the stream will always complete.
Rails 関連
double というメソッドを使うと、モックオブジェクトを作れます。 引数で渡す文字列は任意です。好きな文字列を渡しても構わないですし、省略することもできます。 ... RSpec では allow(モックオブジェクト).to receive(メソッド名) の形で、モックに呼び出し可能なメソッドを設定できます。
その他
- javascript - How can I spy on a getter property using jasmine? - Stack Overflow
- getter の場合どうする =>
spyOnProperty
- getter の場合どうする =>
- node.js - How to clone a javascript ES6 class instance - Stack Overflow
- instance のコピー
- Describing an Interface where unknown properties are of a specific type · Issue #20597 · Microsoft/TypeScript · GitHub
- 複数のオプショナルなプロパティが存在する interface を定義したいときに
type Foo = { name: string; age: number; } & { [prop: string]: string; };