Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Electron - Zone and change detection. #669

Closed
Kaffiend opened this issue Mar 10, 2017 · 1 comment · Fixed by #983
Closed

Electron - Zone and change detection. #669

Kaffiend opened this issue Mar 10, 2017 · 1 comment · Fixed by #983

Comments

@Kaffiend
Copy link

I realize that the MongoDB calls are running outside of zone when used in electron. Is there a more efficient manner of getting the callbacks to work with zone so change detection works properly? Other than running the callbacks through zone.run()? or calling detectChanges manually?

login(userName: string, password: string) {
        this.invalidLogin = false;
        userName = userName.toUpperCase();
        let userColl = this.mongo.db.collection('seFile');
        userColl.findOne(
            { userName: userName, passwordOne: password },
            (err: MongoError, doc: IUser) => {
                this.zone.run(() => {
                    if (err) {
                        this.mongo.mongoError = err;
                    }
                    if (doc) {
                        console.log(doc);
                        this.user = doc;
                        this.authenticated = true;
                        this.invalidLogin = false;
                    } else {
                        console.log(err);
                        this.authenticated = false;
                        this.invalidLogin = true;
                    }
                });
            });
    }

invalidLogin is bound in the template for showing an alert and it doesnt updated properly unless run through zone in the callback. It will show if you click anywhere on the screen afterwards but obviously thats not expected behavior.

@JiaLiPassion
Copy link
Collaborator

@Kaffiend , we will patch mogodb callback later.

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

Successfully merging a pull request may close this issue.

2 participants