请考虑以下事项:
isUserLoggedIn(): Observable<boolean> {
return new Observable((observer) => {
let hash = window.location.hash.substr(1);
let result: any = hash.split('&').reduce(function (result: any, item: string) {
let parts = item.split('=');
result[parts[0]] = parts[1];
if (result.error && result.error == 'access_denied') {
observer.next(false);
observer.complete();
}
else {
this.validateToken(result);
}
let token = this.getAccessToken();
//check if there is a token
if(token === undefined || token === null || token.trim() === '' )
{
//no token or token is expired;
observer.next(false);
observer.complete();
}
observer.next(true);
observer.complete();
}, {});
});
}
我正在创建一个从Gtk.Widget派生的自定义Widget。当我使用这个小部件与Gtk.Builder时,我收到以下错误,程序崩溃:
class MyCustomWidget : Gtk.Widget {
public MyCustomWidget () {
Object ();
}
}
void main (string args[]) {
string ui_string = """
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="MyCustomWidget">
</object>
</interface>
""";
Gtk.init (ref args);
Gtk.Builder builder = new Gtk.Builder.from_string (ui_string, ui_string.length);
}
答案 0 :(得分:1)
这是因为Gtk.Builder尚不知道MyCustomWidget类型。这就是为什么自定义窗口小部件在与Gtk.Builder 一起使用之前应该至少实例化一次。然后可以抛弃此实例。
(bla:22282): Gtk-ERROR **: failed to add UI: .:4:1 Invalid object type 'MyCustomWidget'