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

0.12.0リリースに関するリファクタリング #403

Closed
12 tasks done
kyasbal opened this issue Dec 7, 2016 · 7 comments
Closed
12 tasks done

0.12.0リリースに関するリファクタリング #403

kyasbal opened this issue Dec 7, 2016 · 7 comments

Comments

@kyasbal
Copy link
Member

kyasbal commented Dec 7, 2016

リファクタリング

インターフェース系の定義の簡略化(非破壊的)

  • 完了

現在、ファンクションかつオブジェクトな型を生成するために以下の3つを使っているがこれを解決する。

  • オブジェクト部分のインターフェース
  • 関数部分だけのインターフェース
  • オブジェクト部分の実装

  • オブジェクト部分の実装
  • 関数のインターフェース

今まで

interface AInterfaceBase{
   // それ以外のオブジェクトのプロパティ
}
interface AInterface extends AInterfaceBase{
  // 関数の定義
}

class A implements AInterfaceBase{

}

// Aのインスタンスと関数を混ぜ合わせる処理 -> a

export default a as AInterface;

これから

interface AInterfaceFunction{
   // 関数の定義
}

class A{
  // そのまま実装
}

// Aのインスタンスと関数を混ぜ合わせる処理 -> a

export default a as (A & AInterfaceFunction);

これにより、インターフェースを構成していたファイルをそれぞれ3つから1つに集約できるはず。
また、クラスには定義されているがインターフェース側への定義忘れでアクセスできないというような状況を修正する。

getAttribute/getValueなどの名前の統一(破壊的変更)

  • 議論
  • 完了

現状

   Component#getValue():any 
   Component#getAttribute():Attribute
   Node#getAttribute():any

次期

   Component#getAttribute():any
   Component#getAttributeRaw():Attribute
   Node#getAttribute():any

統一したい。
議論中

ComponentInterfaceの削除(破壊的変更)

いらないぽい

  • 議論
  • 完了

ComponentのAttributeDeclaration(破壊的変更)

  • 完了

現状

{
   converter:string;
   defaultValue:any;
}

次期

{
   converter:string;
   default:any;
}

Attributeのundefinedの扱い(破壊的変更)

  • 完了
  • 属性の初期値がundefinedの場合は例外(この際、コンポーネント名を必ず出す)
  • コンバーターにundefinedを入れたら例外(この際、コンバーター名、所属するノード名の情報を出す)
  • コンバーターは変換できない場合undefinedを返す。

新機能

インターフェース側からのattributeの変更の監視

  • 議論
  • 完了

提案内容

gr("#main")("#aa").watch("属性名",(newAttr,oldAttr)=>
{

});

Attribute#addObserverをAttribute#watchにリネーム(破壊的変更)

  • 完了
Attribute#watch(func:(value:any,oldValue:any,attr:Attribute)=>void,immediate?:boolean);

Attribute.convert

  • 完了
public static convert(converterName:string,val:any):any;

特定のコンバーター名で変換するAPIを追加する。
指定したコンバーターが存在しなかった場合は例外

ガイドライン系

コンバーターのガイドライン

  • これを記述
  • コンバーターは変換不可能な場合、undefinedを返す
  • 例外はコンバーターに指定されるべきオプション(attributesに指定される、default及びconverterでもないもの)に不正があった場合のみ投げても良い
  • コンバーターはundefiedを受け取ることはない

Rleated PRs

#408
GrimoireGL/grimoire.gl-example#1
GrimoireGL/grimoirejs-fundamental#7
GrimoireGL/grimoirejs-gltf#2
GrimoireGL/grimoirejs-preset-basic#1

@moajo
Copy link
Contributor

moajo commented Dec 7, 2016

属性監視はAttribute.addObserverではダメですか?

@pnlybubbles
Copy link
Member

pnlybubbles commented Dec 7, 2016

内部に関して漢壁には把握していないですが、Component.getAttribute("aaa").addObserver(() => {})となっている部分が多々あったので、これと同様にNodeでもやりたいと思ったのですが、既にNode.getAttributeがあるのでどうするのが吉なのかなあと。
ちなみにwatch案はvue由来です。

@kyasbal
Copy link
Member Author

kyasbal commented Dec 7, 2016

@moajo それはまずAttributeがすでに定義されている状態でないととれないのでは?

@moajo
Copy link
Contributor

moajo commented Dec 8, 2016

監視しようとしてる属性が存在しない状況がある?

@kyasbal
Copy link
Member Author

kyasbal commented Dec 8, 2016

あり得る。マテリアルとかの値なら。

@pnlybubbles
Copy link
Member

getAttributeしてしまったじてんでAttributeをつくってしまうのはどうでしょう

@moajo
Copy link
Contributor

moajo commented Dec 8, 2016

typoによるバグが多発しそうだから嫌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants