#declaration of a subject table

14 messages · Page 1 of 1 (latest)

jovial haven
#
  filterArr: any = {} as BehaviorSubject<IFilterLocalisation>;

it works but how I can't replace the any with the subject!

gilded vessel
#

{} is not a behavuoirSubject. What you are doing is wrong

#

this is probably your goal:
filterArr: BehaviorSubject<IFilterLocalisation> = new BehaviorSubject<IFilterLocalisation>({});

jovial haven
#

ok i need a table of BehaviorSubject<IFilterLocalisation>

#

['mysubject1'] = new BehaviorSubject<IFilterLocalisation>({});

#

['mysubject2'] = new BehaviorSubject<IFilterLocalisation>({});

gilded vessel
#

you want an object with behaviourSubjects as keys I guess

jovial haven
#

yes

gilded vessel
#

filterArr: { [x: string]: BehaviorSubject<IFilterLocalisation>; } = {};

jovial haven
#

wouaaa

#

it work

#

thanks !!!

#

I could have found !

gilded vessel
#

just for info, sometimes you create interfaces like this:

export interface MyInterface {
    name: string;
    age: number;
    [x: string]: any;
}

this means you must have name and age and also every other property you want. for example

{
    name: "foo",
    age: 12,
    location: "London",
    data: {test:1}
}

but in your case you only want behavuourSubject, therefore --> [x: string]: BehaviorSubject<IFilterLocalisation>;