My issue is that in my subscribeEquippedItems(): Observable method after 
mapping to an array of type Item for some reason the output is an empty 
array instead of a array.

So just to test that I was getting objects back I did the following in the 
constructor of my class:

this.subscribeTest()
    .subscribe(items => { console.log('TEST: '); console.log(items); });

Which calls the following method in that class:

subscribeTest(): Observable<any> {
    return this.af.database.list('users/uniqueIdIsHere/equippedItems');}

This output an array of 3 objects in the console. They are like this:

[Object, Object, Object]

When opened they look like:

Array[3]
    0: Object
        title: "testtitle"
        active: false
    1: Object
    2: Object

In my class that will display the items I have:

loadItems() {
    this.itemsService.subscribeEquippedItems().subscribe(x => {
        // this.equippedItems = x;
        console.log(x);
    });}

Which calls the itemsService:

subscribeEquippedItems(): Observable<Item[]> {
    let yoyo = Observable.of(new Array<Item>());

    this.session.uid.subscribe(x => {
        console.log('users/' + x + '/equippedItems'); // this is correct vaue
        yoyo = this.af.database.list('users/' + x + '/equippedItems')
            .map(Item.fromJsonList).do(z => {
                console.log('trying to map here');
                console.log(z);
            }).do(s => {
                console.log('STARTSTARTSTARTSTART: ');
                console.log(s); // this shows as an empty array in console
                console.log(' : FINISHFINISHFINISH');
            });
    });
    return yoyo;}

Here is the item class:

public title: string;public active: boolean;
static fromJsonList(array: any): Item[] {
    console.log('tester');
    console.log(array); // blank array shows on console
    return array.map(Item.fromJson);}
static fromJson({title, active}: any): Item {
  return new AvatarItem(title,active);}
constructor(title: string, active: boolean){
    this.title = title;
    this.active = active;}

-- 
You received this message because you are subscribed to the Google Groups 
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to