alsoscotland / react-super-select

MIT License
95 stars 33 forks source link

Support for immutable.js #91

Closed VikLiegostaiev closed 7 years ago

VikLiegostaiev commented 7 years ago

Hi, can you add support for immutable.js like some methods with function argument for iteration ?

alsoscotland commented 7 years ago

@VikLiegostaiev I have been trying keep this control fairly un-opinionated. Requiring that people use Immutable.js may make some people's use cases break. I use the control in projects that leverage Immutable.js and we typically just call

.toJS()

on Immutable lists when providing the dataSource prop

VikLiegostaiev commented 7 years ago

i see, but it affect the performance, doesn't it? If i have big data, so first i must change it toJS and then render, but if you have any default method for iteration, so i can pass my iteration function as argument and render from immutable. Something like this:

superSelectRenderFunc(item) {
      return (
        <li>{item.option}</li>
    )
 }
superSelectFunc(data,iterableFunc) {
   return iterableFunc(data, superSelectRenderFunction);
 }

iterableFunc(list,renderFunc) {
    return list.map((item)=> {
        renderFunc(item);
    });
}

("ReactSuperSelect iterableFunc = {iterableFunc} dataSource={data}> </ReactSuperSelect")

alsoscotland commented 7 years ago

@VikLiegostaiev Sorry for the delayed response. I took a break for the holidays.
I will consider this.

alsoscotland commented 7 years ago

@VikLiegostaiev I don't think I am going to pursue this at the moment. It will have a fair degree of complication around the control. Might be a good candidate for a fork