@catamphetamine/farce
v0.5.0
Published
History repeats itself
Downloads
121
Readme
Farce [![Travis][build-badge]][build] [![npm][npm-badge]][npm]
This is a fork of the original farce package with some changes:
- Fixed empty
location.pathnamebug increateBasenameMiddleware.jswhen using abasename. - Fixed a bug in
createNavigationListenerMiddleware.jswhen it didn't correctly clear navigation listeners onDISPOSEevent. - Replaced
reduxwith a basic stub of it. The rationale is that thereduxthat was used under the hood by this package would conflict with the redux used by the application itself. - Removed unused
createHref()andcreateLocation()actions. - Removed unused
HashProtocol. - Removed
store.farce.addNavigationListener()function. As a replacement, it now exports a new functionaddNavigationListener(). - Removed
createHistoryEnhancer()function. As a replacement, it now exports a new functioncreateReduxMiddlewares().
This fork is exclusively used by react-pages package.
The source code is available at github.com or gitlab.com.
How farce works in general:
- It provides Redux actions that could be dispatched:
type: PUSH— navigates to a page.type: REPLACE— redirects to a page: replaces the current page with the new one without the ability to go "Back" to the current one.type: GO— goes "Back"/"Forward".
- Whenever one of the Redux actions above is dispatched, it emits a
type: UPDATE_LOCATIONRedux action. Theactionproperty of the Redux action will be:"PUSH"when dispatching atype: PUSHaction."REPLACE"when dispatching atype: REPLACEaction."POP"when dispatching atype: GOaction.
- It listens to "Back"/"Forward" navigation: whenever it happens, it emits a
type: UPDATE_LOCATIONRedux action. Theactionproperty of the Redux action will be"POP". - The application could listen to
type: UPDATE_LOCATIONRedux action and read thelocationproperty from that action to always have the up-to-datelocationobject. - No
type: UPDATE_LOCATIONRedux action will be emitted in case of any changes that were made using History API directly, such ashistory.pushState(),history.replaceState(), etc. So those changes to the current URL will go unnoticed by this library.
