5月メモ・リンク集

5 月に調べたことのメモです。

Angular 関連

third party lib

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.

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

Rx 関連

catchError

Rails 関連

double というメソッドを使うと、モックオブジェクトを作れます。 引数で渡す文字列は任意です。好きな文字列を渡しても構わないですし、省略することもできます。 ... RSpec では allow(モックオブジェクト).to receive(メソッド名) の形で、モックに呼び出し可能なメソッドを設定できます。

その他

type Foo = {
  name: string;
  age: number;
} & {
  [prop: string]: string;
};