Skip to content

Instantly share code, notes, and snippets.

@asido
Created July 4, 2016 08:42
Show Gist options
  • Save asido/1a95df961c61b876de85753274cbf568 to your computer and use it in GitHub Desktop.
Save asido/1a95df961c61b876de85753274cbf568 to your computer and use it in GitHub Desktop.
public fetchMaterial(materialId: number): void {
IsSet(materialId);
this.appState.dispatch({ type: StateActions.SET_LOADING, payload: true });
this.apiService.Publications().MaterialsOf({ Id: materialId })
.Search({ $top: 1, $select: "Text" })
.do(() => this.appState.dispatch({ type: StateActions.SET_LOADING, payload: false }))
.subscribe(response => {
this.appState.dispatch({
type: StateActions.PROCESS_CONTENT,
payload: <ProcessContentArgs>{
content: response.value[0].Text,
knownTerms: this.termsService.getKnown(),
ignoredTerms: this.termsService.getIgnored(),
shelvedTerms: this.termsService.getShelved(),
flashcardedTerms: this.flashcardsService.getAllFlashcards(),
flashcardedPhrases: this.flashcardsService.getPhrases()
}
});
}, error => Materialize.toast(`Failed to load the material :(`, 60000));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment