Functional API
See original GitHub issueI’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.
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:
- Created 9 years ago
- Reactions:2
- Comments:17 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
andR.filter
. That doesn’t help with the relevant getters and setters of immutable, but you can useR.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 usingR.compose
orR.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:Not sure Ramda + Immutable is as seamless as many people would like but it’s worked well enough for me for a while now.
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 😃