-
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.
Fix router popstate, update query_update util
- Loading branch information
1 parent
b54f2df
commit 9510a8d
Showing
5 changed files
with
45 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,49 @@ | ||
## Query update | ||
|
||
Updates URL string with new query params<br /> | ||
Updates URL query with new query parameters<br /> | ||
|
||
Has **2** signatures: | ||
- Receives **2** parameters, to change one query paramenter: | ||
- **key** - **String**. Paramenter key | ||
- **value** - **String**. Paramenter value | ||
- Receives **1** parameter, to change multiple parameters: | ||
- **paramenters** - **Object** where key is parameter key and value is paramenter value | ||
- **paramenters** - **Object** where **key** is parameter key and **value** is paramenter value | ||
|
||
<br /> | ||
|
||
```js | ||
import updateURLQuery from 'siegel/lib/client_core/ui/utils/query_update' | ||
|
||
updateURLQuery(history, 'somekey', 'someValue') | ||
console.log(location.search) // '?paramKey=paramValue' | ||
|
||
|
||
// Update single key (1st parameters) with value (2nd parameter) | ||
console.log( | ||
updateURLQuery('paramKey', 'newParamValue') | ||
) | ||
// '?paramKey=newParamValue' | ||
|
||
|
||
|
||
// Update using key value hashmap | ||
console.log( | ||
updateURLQuery({ | ||
paramKey: 123, | ||
anotherKey: false, | ||
emptyValueKey: '' | ||
}) | ||
) | ||
// '?paramKey=123&anotherKey=false&emptyValueKey=' | ||
|
||
|
||
|
||
// Remove some keys passing undefined / null as values | ||
console.log( | ||
updateURLQuery({ | ||
paramKey: null, | ||
anotherKey: 'another_value', | ||
emptyValueKey: undefined | ||
}) | ||
) | ||
// '?anotherKey=another_value' | ||
``` |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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