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

Custom Elementは実用的なのかどうかの検証 #32

Closed
azu opened this issue Dec 21, 2014 · 7 comments
Closed

Custom Elementは実用的なのかどうかの検証 #32

azu opened this issue Dec 21, 2014 · 7 comments
Labels

Comments

@azu
Copy link
Owner

azu commented Dec 21, 2014

IE9+ならCustom Elementsは動かせる。
ReactとかRactiveとかなんでも最近は大体Componentsという仕組みを持っていて、
コンポーネントを意識して作り出してるものってCustom Elementsみたいなものになってる気がする。

なので、それらのライブラリを使ったCustom Elementsのインターフェースに沿ったコンポーネントを作ることは可能なのかを検証したい。

これのメリットはViewがCustom Elementsというインターフェースに沿って操作が行われるようになるので、Viewのライブラリを内部的に変えても問題なくなるという感じにできるかもしれないというのを知りたい。
今、ウェブアプリのアーキテクチャ的にライブラリに強く依存するのがView周りなので、そこをどうやって分離するかの検証。

@azu azu added the TODO label Dec 21, 2014
@azu
Copy link
Owner Author

azu commented Dec 23, 2014

Custom Elementsのライフサイクルイベントは4つで、細かい管理はないので各自やる感じの部分があると思う。

  • createdCallback : loadView
  • attachedCallback: viewWillAppear
  • detachedCallback: viewDidDisappear
  • attributeChangedCallback : onChange

createdCallbackはinitilize処理なので何度も実行されるような処理じゃないという認識

@azu
Copy link
Owner Author

azu commented Mar 5, 2015

@azu
Copy link
Owner Author

azu commented Mar 10, 2015

Custom Elementsを見ることでわかるのは、以下のようなところが大きそう。

  • View(コンポーネント)にライフサイクルが持たされてイベント駆動で書けるようになったこと
    • ちゃんとViewを消した時に、メモリリークにならないように取り除けるタイミングがあること
  • <x-Custom item-name="名前"> 要素の属性がある種値を渡すインタフェースとして定義されたこと
    • コンポーネントといっても実態はJavaScriptになるので、どういうふうに値を渡すかというルールが決まる
    • new xCustom() などのインタフェースも同時に定義できること
    • 手続き的だけじゃなくて、宣言的にもできるという点

@azu
Copy link
Owner Author

azu commented Jun 1, 2015

これReactもやっぱり同じ所に重きがあるような気がしてきた。
dekuとか見てるとまさにタグとしての生き道が見える。
JSXどこまでちゃんとやるのかよくわからないけど、React.createElementというコンポーネントを関数として表現するには以下のようにできるという事を定義出来たのが今後大きな可能性がある感じ。

ReactElement createElement(
  string/ReactClass type,
  [object props],
  [children ...]
)

@azu
Copy link
Owner Author

azu commented Jun 1, 2015

そもそもCustom Elementsってnew MyElement(args);みたいに引数渡せたっけ?

@azu
Copy link
Owner Author

azu commented Jan 12, 2016

Deku 2.0が最小のライフサイクルとして面白い。

@azu
Copy link
Owner Author

azu commented Jan 13, 2019

認識としてpropsがstring以外も渡せないと変化が難しい

@azu azu closed this as completed Jan 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant