question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi, thanks for the amazing helper.

When using this library in conjunction with lodash/fp, I found that the API would be much more powerful if the argument order was changed (iteratee first, data last), and if it was curried, in the spirit of lodash-fp.

I usually define a function called mutate this way:

const mutate = (getter,setter,context?) => (state) => iassign(state,getter,setter,context,{freeze:true})

The resulting function mutate is extremely helpful, as it allows to represent “mutations” in a declarative way. These mutations can then be applied to data. Here is an example of use:

const reducer = (state = initialState, action) => {

    switch (action.type) {

    case "TICK":
        return mutate(
          state=>state.time,
          time=>time+1
        )(state)
        
        ...

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
crubiercommented, Feb 1, 2017

Hi, I just meant to move the option parameter first, not to reverse the argument order completely.

Auto currying is excellent !

1reaction
crubiercommented, Feb 1, 2017

Hi, thank you this is very nice.

However there is only one thing that could be made better: The order of argument could be changed in order to make this more useful: In the curried form, the options should be the first argument and not the last.

Also, to match lodash/fp, and as a matter of usability, it would be nice if it was autocurried, which means that we can call the function with any number of arguments, and it would be curried accordingly.

This would allow to write things like that

import iassign from "immutable-assign"
// We create our instance with no options
iassignFp = iassign.fp( undefined ) 

// ...

var nested1 = { a: { b: { c: [3, 4, 5] } } };

// ...

var mutation = iassignFp(
    (n, ctx) => (n.a.b.c[ctx.i])  ,
    (ci) => (ci + 100) ,
    {i: 1}
);

// ...

var nested2 = mutation(nested1);
// nested2 == { a: { b: { c: [3, 104, 5] } } }

I asked for this feature in your package, because otherwise I would have had to create a fork of your package just to implement this small change.

If you want I can code this and make a pull request. However you are really close right now

Read more comments on GitHub >

github_iconTop Results From Across the Web

nICEr/api.txt at master · resiprocate/nICEr - GitHub
action completes. So, this is standard event-driven programming. The ICE API exports the following major data structures: - nr_ice_ctx -- a single ...
Read more >
NICE CXone RESTful APIs
Develop customizations and integrations with confidence using the same proven APIs used to create NICE CXone products and features. Utilize tested and validated ......
Read more >
7 Nice API for your projects ! - DEV Community ‍ ‍
7 Nice API for your projects ! · Movie database (IMDB) · Food Recipes (spoonacular) · Rick & Morty database · Random Advice...
Read more >
REST API for the BETTER Application - better-lbnl
The BETTER API operates as a simple REST-based api for creating, updating and deleting building and portfolios, and their related analytics. Like most...
Read more >
NICE syndication API | What we do | About
NICE syndication API · makes NICE content accessible through your platforms, systems and services · ensures you always have access to the most...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found