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

コントローラで動的なイベントハンドラのバインド・アンバインドを可能にする #354

Closed
simdy opened this issue Jun 17, 2014 · 1 comment
Assignees
Milestone

Comments

@simdy
Copy link
Member

simdy commented Jun 17, 2014

現在はコントローラに記述されたハンドラを初期化時にバインドし、unbind()またはdispose()によってアンバインドしている。

しかし、場合によってはコントローラの動作中に動的にイベントハンドラをバインドorアンバインドしたいことがあるので、これを可能にする。

@simdy simdy added this to the v1.1.12 milestone Jun 17, 2014
@simdy
Copy link
Member Author

simdy commented Jun 19, 2014

コントローラにon(), off()メソッドを追加する。

  • Controller.on(target, eventName, listener)
  • Controller.off(target, eventName, listener)
  • targetは、コントローラのイベントハンドラのセレクタ記法と同等の文字列、またはイベントターゲットオブジェクトを受け取る。
  • eventNameはコントローラのイベント名の記法と同等の文字列を受け取る。
  • listenerはリスナー関数とする。なお、この関数のシグネチャはコントローラのイベントハンドラと同じ( function(context) )とし、引数contextに渡されるオブジェクトは静的に定義したイベントハンドラと同じとする。また、thisはコントローラオブジェクトとなる。アスペクトの織り込みも行われる(このバージョンでは、on()を呼んだときにh5.settings.aspectsに定義されているアスペクトが使われる)。

fukudayasuo pushed a commit to hifive-labs/hifivemain that referenced this issue Jun 19, 2014
on,offの基本的な動作を確認するテストケースを追加しました。
fukudayasuo pushed a commit to hifive-labs/hifivemain that referenced this issue Jun 26, 2014
createBindObjectsは静的バインドの場合も第3引数にイベントハンドラを取るよう、動的の場合と共通化しました。
bindRequested → isBindRequested、global → isGlobal に変数名を修正。

unbindByBindObjectで、unbindHandlerListからbindObjを取り除くようにしました。
(取り除かない場合は第3引数にtrue指定)

createEventHandlerInfo内の変数direct→isSelector (真偽は反対)にしました。

isJQueryObjectを先頭でキャッシュしました。
fukudayasuo pushed a commit to hifive-labs/hifivemain that referenced this issue Jul 1, 2014
fukudayasuo pushed a commit to hifive-labs/hifivemain that referenced this issue Jul 1, 2014
unbindHandlerList→boundHandlersに変更(バインド中のハンドラをもつ配列なので。)
fukudayasuo pushed a commit to hifive-labs/hifivemain that referenced this issue Jul 1, 2014
viewのメソッドは全て、ルートコントローラが設定されていない(またはview.__controllerが無い)時にエラーになるようにしました。
テストケース追加しました。
@simdy simdy closed this as completed Jul 1, 2014
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

2 participants