-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(serverHistory): create a server History class
Allow for server side routing using a history object designed to work without the browser. Switch all the tests to use the serverHistory class instead of the previous mock.
- Loading branch information
Showing
6 changed files
with
81 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export {makeRouterDriver} from './makeRouterDriver' | ||
export {supportsHistory} from './util' | ||
export {supportsHistory, createLocation} from './util' | ||
export {createServerHistory} from './serverHistory' |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {createLocation} from './util' | ||
|
||
function ServerHistory() {} | ||
|
||
ServerHistory.prototype.listen = function listen(listener) { | ||
this.listener = listener | ||
} | ||
|
||
ServerHistory.prototype.push = function push(location) { | ||
const listener = this.listener | ||
if (!listener) { | ||
throw new Error('There is no active listener') | ||
} | ||
listener(createLocation(location)) | ||
} | ||
|
||
ServerHistory.prototype.createHref = function createHref(path) { | ||
return path | ||
} | ||
|
||
ServerHistory.prototype.createLocation = createLocation | ||
|
||
function createServerHistory() { | ||
return new ServerHistory() | ||
} | ||
|
||
export {createServerHistory} |
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