This repository has been archived by the owner on Mar 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert the redux implementation to typescript
Because I had to install a beta version of redux in order to get it to stop throwing dispatch type errors, based on advice from some issue, I had a subsequent problem with redux-thunk not yet supporting that new version. There was a pull request already though to fix this, so I pulled the changes from [that pr] into my redux-thunk npm package to get it to work. I have a comment on that PR as to exactly what I did. As of this moment though, that PR still isn't quite finished and thus this does not compile. [that pr]: reduxjs/redux-thunk#180
- Loading branch information
Showing
35 changed files
with
351 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { get } from './fetchHttp' | ||
import { IAuthor, ICourse } from '../redux' | ||
import courseApi from './courseApi' | ||
|
||
|
||
class AuthorApi { | ||
getAllAuthors() : Promise<IAuthor[]> { | ||
return courseApi.getAllCourses().then((courses: ICourse[]) => { | ||
let allAuthorEntries = courses.map(course => course.authorId) | ||
|
||
let uniqueAuthors = Array.from(new Set(allAuthorEntries)) | ||
return uniqueAuthors.map((author) => ({id: author})) | ||
}) | ||
} | ||
} | ||
|
||
export default new AuthorApi() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { get, post } from './fetchHttp' | ||
import { ICourse } from '../redux' | ||
|
||
class CourseApi { | ||
getAllCourses(): Promise<ICourse[]> { | ||
return get('courses') | ||
} | ||
|
||
saveCourse(course: ICourse): Promise<any> { | ||
console.log("Saved course: ", course) | ||
return post('courses', course) | ||
} | ||
} | ||
|
||
export default new CourseApi() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.