DrBoolean / immutable-ext

fantasyland extensions for immutablejs
ISC License
490 stars 19 forks source link

Support for index of element in a list in .traverse method #14

Closed Vikasg7 closed 5 years ago

Vikasg7 commented 6 years ago

Hello @DrBoolean, I am a new-comer to FP and have watched all your videos to be able to start using it.
So currently we don't have access to index of element in List().traverse() method. Can you add it?

Basically, from List([1,2]).traverse(Task.of, (ele) => Task.of(ele))
to
List([1,2]).traverse(Task.of, (ele, index) => Task.of(ele))

workaround for now (but it may not be ideal for each situation):
List([1,2]).toMap().traverse(Task.of, (ele, index) => Task.of(ele))
So index becomes the key if we use toMap()

Also, you can take a look at other methods to make sure we have access to the index, if possible.

I hope it is something that is easy for you to implement.

StevenLangbroek commented 5 years ago

@Vikasg7 I've started implementing. As you can see the actual code change is minimal.

Vikasg7 commented 5 years ago

@StevenLangbroek Thanks, I used RXJS instead of Task.

StevenLangbroek commented 5 years ago

@DrBoolean do you still want this change?