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.

I’ve been playing with the library and missed a functional API instead of a class based method one. To play with it i’ve made a little wrapper around the library that just adds the static methods to the classes making the last param the object on which the method will be invoked on.

npm - immutable-fns

That way we can do things like:

// On the immutable-js api
Immutable.Map({}).get('key')
// Added on this library
Immutable.Map.get('key', map)
var Immutable = require('immutable-fns');
var get = Immutable.Map.get;

// Create an immutable data structure
var m = Immutable.Map({a: 1});

// We can use the traditional api (obj.method(param)) or use the functional API
// (fn(...params, obj))
assert.equal(m.get('a'), get('a', m));

This kind of API is really useful sometimes, and doesn’t conflict with the current API (that I have seen). This wrapper may serve to evaluate if this is worth pursuing on the library itself, and it does its job for the moment.

Thanks for your work on the immutable data structures, really hope to see them take off in js-land.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:2
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
iansinnottcommented, Aug 4, 2017

Many of Ramda’s collection functions work quite well with immutable actually, since they dispatch to the relevant method if present. For example R.map and R.filter. That doesn’t help with the relevant getters and setters of immutable, but you can use R.lens to gain at least some of the functionality you’re looking for. Here’s a relevant article. This means you can build up functional pipelines using R.compose or R.pipe that work on immutable objects.

There’s definitely a lot going on in Ramda but you can still import only what you need directly from the src/ directory. Not as convenient as lodash but I believe there’s a babel plugin which can automate this. Manual example:

import map from 'ramda/src/map';

Not sure Ramda + Immutable is as seamless as many people would like but it’s worked well enough for me for a while now.

1reaction
leebyroncommented, Oct 29, 2014

I’m actually going to close this issue. I think it’s decidedly out of scope, but if no one else gets to it first, I probably will write a fp wrapper for this library in the not-too-distant future 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Functional API - Keras
The Keras functional API is a way to create models that are more flexible than the tf.keras.Sequential API. The functional API can handle ......
Read more >
How to Use the Keras Functional API for Deep Learning
The functional API in Keras is an alternate way of creating models that offers a lot more flexibility, including creating more complex ...
Read more >
Guide to the Functional API - Keras Documentation
The Keras functional API is the way to go for defining complex models, such as multi-output models, directed acyclic graphs, or models with...
Read more >
Guide to the Functional API
The Keras functional API is the way to go for defining complex models, such as multi-output models, directed acyclic graphs, or models with...
Read more >
Understanding Sequential Vs Functional API in Keras
The functional API offers more flexibility and control over the layers than the sequential API. It can be used to predict multiple outputs(i.e ......
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