typescript Mixin混合的理解

2021-08-21 01:42:19 字數 1113 閱讀 2352

// disposable mixin

class disposable

}// activatable mixin

class activatable

deactivate()

}class smartobject implements disposable, activatable

interact()

// disposable

isdisposed: boolean = false;

dispose: () => void;

// activatable

isactive: boolean = false;

activate: () => void;

deactivate: () => void;

}let smartobj = new smartobject();

settimeout(() => smartobj.interact(), 1000);

//////

//////

//////

//////

//////

//////

////

// in your runtime library somewhere

//////

//////

//////

//////

//////

//////

////

basectors.foreach(basector => );

});}

單單看官方的示例可能不是很好理解,要知道typescript是不支援多繼承的,smartobj 當new 這個物件時,心中已經很清楚的知道他具備disposable, activatable中的方法和屬性,但是在smartobj並未實現這些disposable, activatable,所以就宣告出來欺騙typescript的檢查的,從而可實現多繼承的功能,在disposable, activatable中也可相互呼叫,因此在smartobj 他們已經在同一類中,混合也可用於對特別複雜的類進行按功能拆分,需注意型別的一致性;

Batch Normalization的理解體會

網路上對於batch normalization的講解也非常多了,本文主要想記錄下對此的心得體會,並總結下我所理解的bn的優勢。在此先mark一下我認為寫得比較全面的資料 bn的原理 文章1 深度學習 深入理解batch normalization批標準化 bn的 batch normalizati...

25 理一理關於tensorflow的各種騷操作

1.tf.squeeze 2.tf.cast 3.tf.expand dims 4.tf.slice 按照指定的下標範圍抽取連續區域的子集 講的不錯 5.tf.gather 按照指定的下標集合從axis 0中抽取子集,適合抽取不連續區域的子集 6.tf.one hot 7.tf.transpose ...

帶大家理一理mvc,MVP,mvvm模式的差別

啥事code block呢,就是邏輯 塊,業務 塊 但是這兩個詞有點不夠見名知義,所以我們發明出了幾個模式的名字 然後,講一講大家常常將的mvc,easy,檢視層,控制層,模型邏輯層,view,control,model 但這個模式一般用於後端,控制層除了主要是用於跳轉和應用邏輯層,將邏輯層的資料庫...