Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Plugin causes double firing of resume event #44

Open
NL33 opened this issue Oct 10, 2019 · 2 comments
Open

Plugin causes double firing of resume event #44

NL33 opened this issue Oct 10, 2019 · 2 comments

Comments

@NL33
Copy link

NL33 commented Oct 10, 2019

I've noticed a strange behavior. I have an app that has a resume event. If I add setOrientation to the resume event, the event fires twice. I have tested this several times and found it consistently to be the case on device.

Plugin version 2.2.1, NS version 5.3.1. Angular. iOS. On plugged in device.

Running with $ tns run ios --bundle...

service.ts:

var orientation = require('nativescript-orientation');
...
constructor(){
   applicationOn(suspendEvent, this.suspendEvent)
   applicationOn(resumeEvent, this.resumeEvent
}

suspendEvent = (args) =>{ }

resumeEvent = (args) => {
  orientation.setOrientation("portrait")  //THIS IS THE LINE THAT CAUSES RESUME EVENT TO FIRE TWICE
}

app.module.ts

 import { Service} from "~/app/service"
...
  constructor(private service: Service){
    this.service.resumeEvent
  }

If I include the orientation.setOrientation("portrait") in the service resume event, like above, the event fires twice if the app is resumed from landscape mode. So, if the phone is in landscape mode when the app resumes, and the setOrientation line is there, the resume event fires twice.

It only fires once if the setOrientation line is not there.

@NathanaelA, I know you are focused on the proplugins version, but this seems to be an odd mystery.

Why might this happen?

@NathanaelA
Copy link
Owner

That is an odd mystery. If you can clone this repo and take the nativescript core demo and add your code and duplicate the issue; send me the URL and I'll look into it. 😀

@NL33
Copy link
Author

NL33 commented Oct 15, 2019

Thanks. I haven't setup up a sample project yet, but have it as a to do.

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

No branches or pull requests

2 participants