forked from gaearon/flux-react-router-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
488 additions
and
605 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,39 @@ | ||
'use strict'; | ||
|
||
import AppDispatcher from '../dispatcher/AppDispatcher'; | ||
import { dispatchAsync } from '../AppDispatcher'; | ||
import ActionTypes from '../constants/ActionTypes'; | ||
import RepoAPI from '../api/RepoAPI'; | ||
import * as RepoAPI from '../api/RepoAPI'; | ||
import StarredReposByUserStore from '../stores/StarredReposByUserStore'; | ||
import RepoStore from '../stores/RepoStore'; | ||
|
||
export default { | ||
requestRepo(fullName, fields) { | ||
if (RepoStore.contains(fullName, fields)) { | ||
return; | ||
} | ||
|
||
// Although this action is currently not handled by any store, | ||
// it is fired for consistency. You might want to use it later, | ||
// e.g. to show a spinner or have a more detailed log. | ||
|
||
AppDispatcher.dispatch({ | ||
type: ActionTypes.REQUEST_REPO, | ||
fullName | ||
}); | ||
|
||
RepoAPI.requestRepo(fullName); | ||
}, | ||
|
||
requestStarredReposPage(login, isInitialRequest) { | ||
if (StarredReposByUserStore.isExpectingPage(login) || | ||
StarredReposByUserStore.isLastPage(login)) { | ||
return; | ||
} | ||
|
||
if (isInitialRequest && StarredReposByUserStore.getPageCount(login) > 0) { | ||
return; | ||
} | ||
export function requestRepo(fullName, fields) { | ||
// Exit early if we know about this repo | ||
if (RepoStore.contains(fullName, fields)) { | ||
return; | ||
} | ||
|
||
AppDispatcher.dispatch({ | ||
type: ActionTypes.REQUEST_STARRED_REPOS_PAGE, | ||
login | ||
}); | ||
dispatchAsync(RepoAPI.getRepo(fullName), { | ||
request: ActionTypes.REQUEST_REPO, | ||
success: ActionTypes.REQUEST_REPO_SUCCESS, | ||
failure: ActionTypes.REQUEST_REPO_ERROR | ||
}, { fullName }); | ||
} | ||
|
||
export function requestStarredReposPage(login, isInitialRequest) { | ||
// Exit early if already fetching, or if there is nothing to fetch. | ||
if (StarredReposByUserStore.isExpectingPage(login) || | ||
StarredReposByUserStore.isLastPage(login)) { | ||
return; | ||
} | ||
|
||
const nextPageUrl = StarredReposByUserStore.getNextPageUrl(login); | ||
RepoAPI.requestStarredReposPage(login, nextPageUrl); | ||
// Ignore first page request when component is mounting if we already | ||
// loaded at least one page before. This gives us instant Back button. | ||
if (isInitialRequest && StarredReposByUserStore.getPageCount(login) > 0) { | ||
return; | ||
} | ||
}; | ||
|
||
const nextPageUrl = StarredReposByUserStore.getNextPageUrl(login); | ||
dispatchAsync(RepoAPI.getStarredReposPage(login, nextPageUrl), { | ||
request: ActionTypes.REQUEST_STARRED_REPOS_PAGE, | ||
success: ActionTypes.REQUEST_STARRED_REPOS_PAGE_SUCCESS, | ||
failure: ActionTypes.REQUEST_STARRED_REPOS_PAGE_ERROR | ||
}, { login }); | ||
} |
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 |
---|---|---|
@@ -1,45 +1,39 @@ | ||
'use strict'; | ||
|
||
import AppDispatcher from '../dispatcher/AppDispatcher'; | ||
import { dispatchAsync } from '../AppDispatcher'; | ||
import ActionTypes from '../constants/ActionTypes'; | ||
import UserAPI from '../api/UserAPI'; | ||
import * as UserAPI from '../api/UserAPI'; | ||
import UserStore from '../stores/UserStore'; | ||
import StargazersByRepoStore from '../stores/StargazersByRepoStore'; | ||
|
||
export default { | ||
requestUser(login, fields) { | ||
if (UserStore.contains(login, fields)) { | ||
return; | ||
} | ||
|
||
// Although this action is currently not handled by any store, | ||
// it is fired for consistency. You might want to use it later, | ||
// e.g. to show a spinner or have a more detailed log. | ||
|
||
AppDispatcher.dispatch({ | ||
type: ActionTypes.REQUEST_USER, | ||
login | ||
}); | ||
|
||
UserAPI.requestUser(login); | ||
}, | ||
|
||
requestStargazerPage(fullName, isInitialRequest) { | ||
if (StargazersByRepoStore.isExpectingPage(fullName) || | ||
StargazersByRepoStore.isLastPage(fullName)) { | ||
return; | ||
} | ||
|
||
if (isInitialRequest && StargazersByRepoStore.getPageCount(fullName) > 0) { | ||
return; | ||
} | ||
export function requestUser(login, fields) { | ||
// Exit early if we know enough about this user | ||
if (UserStore.contains(login, fields)) { | ||
return; | ||
} | ||
|
||
AppDispatcher.dispatch({ | ||
type: ActionTypes.REQUEST_STARGAZER_PAGE, | ||
fullName | ||
}); | ||
dispatchAsync(UserAPI.getUser(login), { | ||
request: ActionTypes.REQUEST_USER, | ||
success: ActionTypes.REQUEST_USER_SUCCESS, | ||
failure: ActionTypes.REQUEST_USER_ERROR | ||
}, { login }); | ||
} | ||
|
||
export function requestStargazerPage(fullName, isInitialRequest) { | ||
// Exit early if already fetching, or if there is nothing to fetch. | ||
if (StargazersByRepoStore.isExpectingPage(fullName) || | ||
StargazersByRepoStore.isLastPage(fullName)) { | ||
return; | ||
} | ||
|
||
const nextPageUrl = StargazersByRepoStore.getNextPageUrl(fullName); | ||
UserAPI.requestStargazerPage(fullName, nextPageUrl); | ||
// Ignore first page request when component is mounting if we already | ||
// loaded at least one page before. This gives us instant Back button. | ||
if (isInitialRequest && StargazersByRepoStore.getPageCount(fullName) > 0) { | ||
return; | ||
} | ||
}; | ||
|
||
const nextPageUrl = StargazersByRepoStore.getNextPageUrl(fullName); | ||
dispatchAsync(UserAPI.getStargazerPage(fullName, nextPageUrl), { | ||
request: ActionTypes.REQUEST_STARGAZER_PAGE, | ||
success: ActionTypes.REQUEST_STARGAZER_PAGE_SUCCESS, | ||
failure: ActionTypes.REQUEST_STARGAZER_PAGE_ERROR | ||
}, { fullName }); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.