This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I have added a small datastore to my ionic app which is essentially built upon beahviourSubject. I use this method in all of my Angular apps from V2 onwards and in all my previous Ionic 3 apps - never had an issue.
I have just built my first Ionic 4 app and now that I am running two users in conjunction I am seeing some weird behaviour.
Any standard page i.e created with ionic g page pages/myPageName does not have it's UI updated as data is pushed to the datastore
Any standard component created with ionic g component /components/myComponentName does have the UI updated as soon as the datastore changes.
This is very weird and worrying as I have the have this build completed tomorrow and this is a last moment potential disaster. Has change detection changed from V3 to V4? Does Ionic depart from the standard Angular change detection?
any help greatly appreciated.
example code:
In my page I add this above the constructor to create the observable:
import {Store} from '../../store';
user$ = this.store.select<any>('user')
constructor(private store: Store) {}
my store.ts
import {pluck, distinctUntilChanged} from 'rxjs/operators';import {BehaviorSubject, Observable} from 'rxjs';import {State} from './state';const state: State = {user: undefined, ... and others}
export class Store {private subject = new BehaviorSubject<State>(state);private store = this.subject.asObservable().pipe(distinctUntilChanged());get value() {return this.subject.value;}select<T>(name: string): Observable<T> {return this.store.pipe(pluck(name));}selectForLocal(name: string) {const d = this.subject.value;return d[name];}set(name: string, state: any) {this.subject.next({...this.value, [name]: state});}}
Post Details
- Posted
- 5 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/ionic/comme...