Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assigning value to code programatically not working after first time. #18

Closed
moshe5745 opened this issue Nov 19, 2020 · 6 comments
Closed

Comments

@moshe5745
Copy link

If you assigned value for the first time it works.
But the second time its not.

this.code = '1111'; // works
... some code ...
this.code = '2222' // doesn't work

I found a workaround, but still i think its need a fix.
this.code = '1111'; // works
... some code ...
this.code = '2222'
setTimeout(() => this.code = '2222' // works

But this workaround only works if the previous value of code wasn't empty string.
this.code = '1111'; // works
... some code ...
this.code = ''
setTimeout(() => this.code = '2222' // doesn't works

But if we assigned undefined it works
this.code = '1111'; // works
... some code ...
this.code = undefined
setTimeout(() => this.code = '2222' // works

@AlexMiniApps
Copy link
Owner

@moshe5745 Hi. ok. I will add the fix for that.

@AlexMiniApps
Copy link
Owner

AlexMiniApps commented Nov 20, 2020

@moshe5745 I have checked the current version of the lib and it works as expected. I have used the latest version '1.2.2'.
You can check it by yourself:

  1. Unpack the attached archive
    test-app-copy.zip

  2. From the project folder run npm install

  3. From the project folder run ng serve

In your code please check that the value is changed during different browser events loop. If the changing will be in the same event loop the last value for the current loop will be used. Also please ensure that you use the latest lib version

Example 1 with the same evet loop:

... some sync  code ...
this.code = 1234
... some sync  code ...
this.code = 5555

The last value will be shown in the component - 5555

Example 2 with the different event loops:

... some sync code ...
this.code = 1234
... some sync  code ...
this.code = 5555
... some sync  code ...
setTimeout(() => this.code = 7777) // will be called async in the next loop

The last value for the latest event of the browser will be shown in the component - 7777

@moshe5745
Copy link
Author

I downloaded and ran your code and its working properly.
Maybe its because i use ionic app, and not just angular.

@AlexMiniApps
Copy link
Owner

@moshe5745 I have also checked the lib on the Ionic. Please check the attachment, it is the Ionic project.
blank-copy.zip

@AlexMiniApps
Copy link
Owner

@moshe5745 Have you solved the issue?

@AlexMiniApps
Copy link
Owner

Closing as not reproducible

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

No branches or pull requests

2 participants