Page router outlet global tap event - nativescript

Im trying to create a session timeout when the user is idle for 1 min. I'm planning to use tap event from the topmost page, page-router-outlet (tap)="globalTap()" and reset the timer whenever this tap event is fired. Also, i think i'll add all the user events like swipe, double tap etc. to reset the timer.
Is this the best approach to this problem? Are there sideffects on catching global events on the page router outlet?
Similar question, Detect App inactivity/idle timeout in NativeScript, but Im not keen on the solution because its for android only and it seems like a patch for me.

Related

Dialog box not resolving on click in Cypress

I'm having a problem where when I click on submit in a dialog box the resolve event on the dialog box is supposed to call a function. The dialog closes when the button is click but the api function is never called (as seen from dev tools). If I stop the tests and manually do the action in the cypress browser it will work call the function. I'm not sure why the manual click is acting different than the test runners click?
Sometimes you need a hard ms wait(should be avoided)...
You may have a wait issue. Add a cy.wait(1000) 1000ms hard wait and see if that fixes it. If it does, you will want to identify what hasn't loaded fully when the button is pressed. While hard waits should be strongly avoided, I find myself using them sparingly with the smallest amount of milliseconds(x2 for safety) that I can get by with. Animations are one such example that comes to mind.
Make sure all subscriptions are ready
I am working on a meteor app that using websockets(tricker to wait on than xhr events). I call a method that returns true/false for all subscriptions. This helps wait for any events that cypress doesn't see in the network layer. Ask your devs if there is a method in your application that returns true/false depending on the ready state of the application.
Review for Race condition
This could be a legitimate race condition. I would review it with the devs just in case.

Xamarin.Forms Timer doesn't skip UI logic even when it's not showing?

I'm making a app with using XF PCL.
I started to doubt that XF's timer is not good enough for UI routine.
for example, in iOS native app, If View is not showing some reason (new page's pushed or something), scheduler is stopped automatically. Because it's for UI.
But Xamarin's doesn't seem like that.
It's still doing his job.
I hope at least within "Device.BeginInvokeOnMainThread(() =>" will be skipped when it's disappeared.
Am I right?
Should I put extra logic for that?
(like stop and restart timer?)
(or declare variable to skip in it?)
Thanks.
In Andriod usually when you are in Page1 and then you navigated to Page2, although Page1 is hidden it is not killed therefore the worker threads would still working (in that case it is the timer)
My suggestion is to override the OnDisappearing method in the code behind of Page1 and place the code that would make the timer stop or being ignored.
If it is for me , I would also place a boolean flag and called _isPageShown so when you override OnDisappearing and OnAppearing you just put the value of _isPageShown to false or true accordingly. Then in the callback of the timer you check the flag if it is true or false and act accordingly.

NSView keyDown not called during drag and drop in Cocoa application

I have a cocoa application where i need to respond to keyDown events during dragging sessions in order to trigger other things. The keys are not modifiers only but can be any kind of key.
The problem is, when i start a dragging session by calling NSWindow.dragImage, i don't get keyDown events during that dragging operation. When i drag an external resource over/into the application window (e.g. a file from Finder) it works fine, NSView.keyDown gets called.
Is there any way of getting around this? Thanks you!
This is probably because the dragging session is using a 'mouse-tracking loop' to handle the drag events. This effectively blocks all other events from being sent to their targets except for the drag events. You can read about this here in the event documentation.
The reason dragging items onto your app does NOT do this is because only the app initiating the drag session is event blocked, not the app receiving the drop.
Having said this, you could try to capture the keyEvents during the mouseDragged event using nextEventMatchingMask:untilDate:inMode:dequeue: this should allow you to pop-off any key events that might be in the event queue.
Also in the documentation linked above they discuss handling key events during mouse drag operations. However the examples don't specifically fit when initiating a drag session with dragImage:at:offset:event:pasteboard:source:slideBack: but you may try watching the performKeyEquivalent as they mention or even seeing if NSWindow's sendEvent: is receiving events during the drag session.

Handling windows button during Async BeginGetResponse in wp7

is there any way to handle the Windows button keypress within the *.Xaml.cs especially when the app is busy getting a request processed using an Asynchronous BeginGetResponse. is there a override handler like OnBackKeyPress?
What's the appropriate way to handle this use case? i'm already handling Application_Activated and deactivated in the App.Xaml.cs file for tombstoning.
You can't stop this from happening. When this happens the current page will get its OnNavigatedFrom override called so you could clean up your page and save state from this method.
Bear in mind that it won't be possible to tell whether this is due to the hardware Start key or if the user just navigated away by say pressing the Back key or tapping a button.
Update:
If you're trying to avoid a crash due to Fast App Switching interrupting your networking call you should rather handle this when you return to the application. Your WebRequest will be cancelled and you should handle this case as shown in this MSDN blog post.

Stop back button during data pull?

Is it possible to stop the back button from working during a data call? For instance, when registering, I don't want someone to press the back button otherwise they may register for my service and not know it (other than confirmation email)? (And the registration will fail the next time they try)
Handle the BackKeyPress event or override the OnBackKeyPress method in your page class, and then set e.Handled = true; when you want to prevent backwards navigation.
Note that if you do this, then you should provide the user with a way to cancel your long-running process so they can back out if they want to.
Please note that if you stop the Back button from working your application will fail marketplace submission.
See section 5.2.4 Use of Back Button.
If a user has the situation where they try to reregister (becuase they don't realise they have registered previously) then you should handle this in your app as the situation may come up anyway.

Resources