Comments (1)
Hey!
Actually, the issue isn't on ngFor
but on how loaded
works in NativeScript. Loaded emits when the native view is loaded, even if it means it's in the middle of ChangeDetection. This works sometimes in other places because during navigation and bootstrap the views aren't created synchronously as they are when you're using a delayed ngFor.
ngFor does container.createEmbeddedView(template, null)
(null being the context) and then manually patches the context, but loaded is happening during createEmbeddedView
, so it passes an invalid context to the event.
The new angular integration has just been released (https://blog.nativescript.org/nativescript-angular-12/index.html) and we're wondering on how to best handle this case. Here are the options and pros/cons:
-
make all events async.
pros: no more events mid-cd and others
cons: events are no longer synchronous and can no longer be easily modified. unloaded will never fire as it fires DURINGngOnDestroy
(that removes listeners afterwards) -
add some kind of event prefix that will fire events async
(ngSafe-loaded)='loaded(data)'
pros: more power to developers
cons: a bit frustrating to have this issue happen and have to use this as a workaround -
treat loaded differently and always fire it async
pros: same API and everything
cons: loaded may fire after unloaded! If you create and destroy a component in the same task it may happen. This could get hairy quickly. Other events could also be affected but only loaded is patched -
Do nothing. Developers can solve this pretty easily by adding a custom directive like
safeLoaded
that is an@Output
with asetTimeout(emit(),0)
. We can then add this to the documentation.
It seems there isn't an easy way out of this. On one hand, the event is firing correctly when it should, on the other, it's frustrating to use loaded
and have it work differently depending on how it's used. I'm open to suggestions on how to best handle this scenario.
Part of me says we should make clear that loaded
and unloaded
are not "safe" events, and another part says we should make them behave like the web, which might just be impossible for unloaded.
from nativescript-angular.
Related Issues (20)
- Livesync doesnt work with two android emulator
- [Android] Keyboard overlap content when router in use
- ERROR NullInjectorError: R3InjectorError(AppModule)[Page -> Page -> Page]: HOT 7
- Question - Showing an nativescript angular app in a angular website HOT 4
- Nativescript/Angular app UI is freezing HOT 5
- Angular 12 migration leads to huge amounts of Change Detection cycles HOT 1
- Nativescript iOS & Android runtime issue module not found
- (android) Navigation does not work when the app is started while the device is locked HOT 4
- Cannot read property 'call' of undefined
- iOS 15 status bar issue HOT 1
- [Element] is not a known element HOT 1
- [iOS] Issue while opening dialogs inside a modal
- Error on run blank Angular project HOT 2
- Android : ModalDialogOptions in Nativescript/Angular fails and throws an exception
- Wrapping a spec in fakeAsync results in ProxyZone error on a new app HOT 2
- Generate component does not add automatically to module
- bottom navigation bar nativescript
- Error: Need to call TestBed.initTestEnvironment() first
- FontAwesome 6 icons not showing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nativescript-angular.