Giter VIP home page Giter VIP logo

immutable-lens's People

Contributors

couzic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

immutable-lens's Issues

API Design overhaul

  • view()
  • set()
  • setPartial()
  • setFields()
  • setFieldPartials()
  • update()
  • updatePartial()
  • updateFields()
  • updateFieldPartials()
  • pipe()

Lens.set()

const updater: Updater<Source> = lens.set(newValue)

const updatedSource: Source = lens.set(newValue, source)

Lens.pick(...fields)

pick<K extends keyof Target>(...keys: K[]): (from:Target) => Pick<Target, K> {
   ...
}

Feature request: Arrays

Hi, first off, thanks for making this.

I'm using your library in a project and ran into an issue. I have a dimensional array
[ [0,0,0], [0,0,0]]

Creating a lens using focusPath(0,0) to update, I get back something like this

{
 0: {0: 1, 1: 0, 2: 0},
 1: [0, 0, 0]
}

Which isn't expected. I would expect the update return the same type it started with. I don't believe the current behavior is intuitive.

Thanks

Bind reading functions to the lens

It would allow more concise syntax. For example:

const state$: Observable<State> = ...
const lens = createLens<State>

const a$: Observable<A> = state$.map(state => lens.focusOn('a').read(state))

The last line could be written:

const a$: Observable<A> = state$.map(lens.focusOn('a').read)

Lens.updateFieldValues()

Add the ability to do something like:

const switchValues = lens.updateFieldValues(state => ({
   prop1: state.prop2,
   prop2: state.prop1
}))

Currently, this can be achieved with: (which is not that bad, really...)

const switchValues = lens.update(state => ({
   ...state,
   prop1: state.prop2,
   prop2: state.prop1
}))

Lens.view()

const selector: (source: Source) => Target = lens.view()

const target: Target = lens.view(source)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.