nativescript-vue / nativescript-vue-navigator

A simple router for NativeScript-Vue, built on top of $navigateTo to simplify routing from within components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Data binding stopping?!

eullerpereira94 opened this issue · comments

Hello, I'm facing a strange problem regarding watchers and navigation. I'm making an app that needs a user to be authenticated, nothing extraordinary. There is a simple login screen that makes requests to my authentication API and navigates the user to the home screen if the credentials are ok, nothing fancy here.
But there's one simple thing that the login screen does, it has a watcher to the password, to guarantee that it has at least 8 chars, and a watcher to the login, to guarantee that it has exactly 11 chars and all of them are numbers. And together, those two watchers set a boolean variable that controls if my login button is enabled or not.
The problem is: the watcher do work, but only if the app is open when it was not in background(i.e., it was the first time the app was open or if I manually killed it before). If I push the logout button and make the app navigate to the login screen, then the watchers stop working, and I have to manually kill the application and reopen it, so I can login again.
Do you have any suggestions of what might be?

Not sure without being able to investigate further, but using a watcher in the first place is not a great idea. A computed property should work much more reliably, and would likely be a simpler solution.

Removed all watchers and reimplemented everything using computed properties. Turns out that they weren't the problem. The app just stops listening to changes in the properties. I've set up three labels in the screen whose values are the login string property, the password string property and the valid computed boolean property. If I logout from the app, using the $navigator.push() method, the data binding just stops. It doesn't matter what I type, the labels won't update their text. I need to restart the app in order for everything to start working again.

Little update, events are still being emitted from the inputs, but the the text provided by the user is not being sent to properties of my login component. This is getting really weird. Maybe is not a problem with nativescript-vue-navigator at all, but with nativescipt-vue itself. There is this message: getFrameById() is deprecated. Use Frame.getFrameById() instead. that keeps popping up in the terminal. I don't know if this is the cause, but is really suspicious.

getFrameById() is deprecated. Use Frame.getFrameById() instead. is a warning that has been fixed in NativeScript-Vue 2.5.0.

If still having issues (i know this is fairly old now), open a new issue - I'll close this one for now.