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

New lens helper for React users #268

Merged
merged 6 commits into from Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
@@ -1,4 +1,7 @@
# 1.55.1
stellarhoof marked this conversation as resolved.
Show resolved Hide resolved
# 1.56.0
- New lens helper for React users: `stateLens`

# 1.55.1
- Fix issue with autoLabelOption not accepting correctly falsy values as valid options

# 1.55.0
Expand Down
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -560,6 +560,10 @@ To help illustrate the potential use cases of the power of lenses, these are som
#### domLens.binding
`(field, getValue) -> lens -> {[field], onChange}` Even more generic utility than targetBinding which uses `getEventValue` to as the function for a setsWith which is mapped to `onChange`.

### Lens Utils

#### stateLens
`([value, setValue]) -> lens` Given the popularity of React, we decided to include this little helper that converts a `useState` hook call to a lens. Ex: `let lens = stateLens(useState(false))`.

## Aspect
Aspects provide a functional oriented implementation of Aspect Oriented Programming.
Expand Down
8 changes: 0 additions & 8 deletions karma.conf.js
Expand Up @@ -269,14 +269,6 @@ let customLaunchers = {
deviceName: 'iPad Pro (9.7 inch) Simulator',
deviceOrientation: 'portrait',
},
sl_android_44: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base: 'SauceLabs',
browserName: 'android',
version: '4.4',
deviceName: 'Android Emulator',
deviceType: 'phone',
deviceOrientation: 'portrait',
},
sl_android_51: {
base: 'SauceLabs',
browserName: 'android',
Expand Down
3 changes: 2 additions & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "futil-js",
"version": "1.55.1",
"version": "1.56.0",
"description": "F(unctional) util(ities). Resistance is futile.",
"main": "lib/futil-js.js",
"scripts": {
Expand Down Expand Up @@ -55,6 +55,7 @@
"chokidar-cli": "^1.2.0",
"codacy-coverage": "^3.0.0",
"coveralls": "^3.0.0",
"danger": "^6.1.13",
"duti": "latest",
"eslint": "4.19.1",
"eslint-config-smartprocure": "^1.0.2",
Expand Down
2 changes: 2 additions & 0 deletions src/lens.js
Expand Up @@ -91,3 +91,5 @@ export let domLens = {
targetBinding,
binding,
}

export let stateLens = ([value, set]) => ({ get: () => value, set })