Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add createQueryAtom #4

Closed
Olian04 opened this issue Nov 5, 2022 · 0 comments · Fixed by #14
Closed

Add createQueryAtom #4

Olian04 opened this issue Nov 5, 2022 · 0 comments · Fixed by #14
Assignees
Labels
enhancement New feature or request

Comments

@Olian04
Copy link
Owner

Olian04 commented Nov 5, 2022

const A = createQueryAtom({
   key: 'a',
   default: 0,
});

A.get() // 0

A.set(v => v + 1) // Will update query parameter "a" to be 1

// Page reload...

location.search // "?a=1"
A.get() // 1

A.set(2);

// Page reload...

location.search // "?a=2"
A.get() // 2

A.set(0);

// Page reload...

location.search // ""
A.get() // 0
// "a" is removed from query since its equal to its default value


// For creating links that update the page state
A.urlWhenSet(4); // www.domain.com?a=4
@Olian04 Olian04 added the enhancement New feature or request label Nov 5, 2022
@Olian04 Olian04 self-assigned this Nov 5, 2022
@Olian04 Olian04 changed the title Add persistance Add persistance composites Nov 24, 2022
@Olian04 Olian04 changed the title Add persistance composites Add createQueryAtom Nov 24, 2022
Olian04 added a commit that referenced this issue Nov 27, 2022
@Olian04 Olian04 linked a pull request Nov 27, 2022 that will close this issue
Olian04 added a commit that referenced this issue Nov 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant