Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObservableArrayの値へのアクセスをget(), set()で行うようにし、添え字によるアクセスを廃止 #170

Closed
simdy opened this issue Feb 14, 2013 · 0 comments
Assignees
Milestone

Comments

@simdy
Copy link
Member

simdy commented Feb 14, 2013

ObservableArrayは配列に対する操作をイベント機構で外部から監視可能にするためのクラス。
ver.1.1.2までは、特定のインデックスに対する値の取得・代入は

  • 取得:添え字(value = obsArray[index])
  • 代入:splice()を使用(obsArray.splice(index, 1, value))

で行うこととしていた。

しかし、代入を添え字で行われた場合、それは外部には通知されない。
オブジェクトプロキシの機構がない現状のJavaScriptの仕様では、配列への添え字による代入はフックできない。
また、特定インデックスへの代入をsplice()で行うという仕様は、
動作自体は問題ないものの、ややわかりづらいものであった。

さらに、値の取得は添え字で行い、その他のメソッドも配列と同じであることから、
通常使用していると(本物の)配列と混同する恐れがあった。

そこで、「中途半端に配列のようにアクセスできる」という仕様を改善・変更し、
取得・代入をともにメソッドベースで行うよう変更する

取得を添え字アクセスにしたままset()を追加する方法も考えられるが、
通常の配列のように思われる危険性をなくすため、またAPIの対称性のため、get()でのアクセスとする。

@ghost ghost assigned simdy Feb 14, 2013
simdy pushed a commit to hifive-labs/hifivemain that referenced this issue Feb 14, 2013
simdy pushed a commit to hifive-labs/hifivemain that referenced this issue Mar 8, 2013
simdy pushed a commit to hifive-labs/hifivemain that referenced this issue Mar 8, 2013
simdy pushed a commit to hifive-labs/hifivemain that referenced this issue Mar 8, 2013
simdy pushed a commit to hifive-labs/hifivemain that referenced this issue Mar 8, 2013
simdy pushed a commit to hifive-labs/hifivemain that referenced this issue Mar 8, 2013
@simdy simdy closed this as completed Mar 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant