- リストでチェックボックスのついてるやつをReact + Fluxでつくる
- このときのjsレイヤのデータ構造をどうするか
- 単純にリストにするとアクションを適用するオブジェクトを選ぶのにfilterしないといけないのでは?
{
action: "LIST_SELECTED",
id: 123,
}
const HogeRecord = new Record({
id: undefined,
name: undefined,
price: undefined,
selected: false,
});
class Hoge extends HogeListRecord {
}
const hogeLists = new List([hoge0, hoge1,...]);
- そのままListを使う
- filterなどを使って見つける
- O(n)はかかる
- 表示するHogeオブジェクトが少ないなら問題ない
- OrderedMapに突っ込む
- O(1)?で引けるがListではなくなる
- これでいいのか
OrderedMapしかなさそう
もしあんまりアクセスが無いなら逐一XHRでサーバ側に反映しても良さそう。あるいは、ブラウザにDBを持つか。