我有兩個類,我希望一個類可以訂閱另一個類。所以 這樣的事情。 類別之一: while(1){ if(true){ //emmit some event } 類二: //wait for class one to emmit some data ,and then start working with the data 我的問題是,有沒有什麼方法,模塊..這可以幫助我實現了這個行爲?
我做了一個服務名爲UserEvents @Injectable()
export class UserEvents {
public evAuthenticated: EventEmitter<string> = new EventEmitter();
public AuthUserEvent(email: string) {
this.evAuthenticated.next(ema
我有一個具有has_one配置文件的用戶模型。當我像這樣創建用戶時,配置文件會自動創建; class User < ActiveRecord::Base
has_one :profile, dependent: :destroy
after_create :create_profile
end
class Profile < ActiveRecord::Base
我有一個對象變量a,它有一個與它關聯的數組,b。我將b傳遞給一個函數,並且需要檢查與其關聯的對象中的屬性。 我該怎麼做?我可以以某種方式使用事件發射器嗎? function ObjectB (stuff) {
this.a = new a();
}
function doSomething (s) {
//need to get b from a
}
var b = new