2016-06-26 7 views
0

ngrx/effectsを使用しています。TypeError:不明な型が返されました

this.store.dispatch({ type: CHAT_LOAD_MESSAGES, payload: chatId }); 

    @Effect() loadMessages$ = this.updates$ 
    .whenAction(CHAT_LOAD_MESSAGES) 
    .map<string>(toPayload) 
    .do(chatId => console.log('chatId', chatId)) // Here I can get chatId 
    .switchMapTo(chatId => this.chatService.loadMessages(chatId)) // The error comes out because of this line 
    .do(res => console.log('res', res))    // This didn't run 
    .map((messages: Message[]) => ({ type: CHAT_LOAD_MESSAGES_SUCCESS, payload: messages })); 

loadMessages(chatId: string): Observable<Message[]> { 
    // This is what I am using to test right now. 
    // Maybe this line is wrong? How can I write correct simulation? 
    return Observable.of([{ id:1, content:'Hi' }); 
    } 

これは何を引き起こす可能性があります。

ORIGINAL EXCEPTION: TypeError: unknown type returned

これは私のコードの一部です:私はこのエラーを得ましたか。ありがとう

答えて

0

@apregありがとうございましたGitterで私のエラーを指摘します。

switchMapToswitchMapに変更する必要があります。

switchMapswitchMapToの公式ドキュメントと説明。

+1

ちょうどそう;) – apreg

関連する問題