Ionic 4 what is equivalent of v3 content.resize()?

#1

I have a pwa using version 3 that I am converting to version 4, but for the life of me, I cannot find or figure out the equivalent of version 3 content.resize(). Any help would be appreciated

#2

I think I submitted an issue about this, the method is there but private. The answer of the team was that it might not be needed anymore.

So I would say give a try without, if it doesn’t work, could you give a feedback with maybe a bit of details? I guess they wont be against making it public but if needed you know what I mean

Ps the issue https://github.com/ionic-team/ionic/issues/14875

#3

Thanks for your reply and the links. I am having a few problems with the ion-list, however, I will continue trying to sort it out without content.resize(). It may well be a problem created by me.

1 Like
#4

Keep us updated will be interesting

#5

Just some background:
I am updating and array of data (from pouchDb) from a ‘changes feed’. This array is bound to an ion-list where each line is a card. The updating of the array for those users that did NOT initiate the change happens in the background when the change emitter spots the change made elsewhere.

The changes take place satisfactorily, however, it is not until the user clicks anywhere on the screen that the change becomes visible. I am using IONIC SERVE by the way, where I observe things on my laptop, but make the changes from my phone.

I have experimented with changing arrays bound to an ion-list with or without cards using a timer as the emitter and everything works fine.

At this point in time I can only conclude that I am doing something wrong. I am going to have more opportunities (using the same pattern which I now need to refine) to spot the problem. When and if I do I will advise.

#6

Two suggestions

Wrap in a an angular zone as the change detection mechanism of angular does not pick it up (e.g. through some cordova plugin)

Call the private method resize anyway. I wonder if javascript enforces no calling to private methods of classes as clases basically dont exist in javascript (only typescript)

Tom

#7

Thanks Tommertom, your first suggestion sent me in the right direction and I found a solution which was:

A.import { NgZone } from ‘@angular/core’;
B.constructor(public ngZone: NgZone…etc…){}
C.this.zone.run(() => this.customerList = x)

where x is the changed list returned from a promise. This in effect manually triggers change detection and the list is updated.

Thanks for pointing me at zones. I am now a happy chappy!

2 Likes
#8

Just a follow up with another way of achieving a refresh.

A. import {ApplicationRef} from ‘@angular/core’;
B. constructor {public app: ApplicationRef,…}
C. app.tick()

I was looking at zones etc and found this and it also seems to work.
Just in case it is useful.

1 Like