cooperka / react-native-immutable-list-view

:scroll: Drop-in replacement for ListView, FlatList, and VirtualizedList.
MIT License
205 stars 30 forks source link

Available to accept `seamless-immutable` #31

Closed sujameslin closed 6 years ago

sujameslin commented 6 years ago

For now, i can't use this component with seamless-immutable. I'm getting immutableData.isEmpty is not defined error. Since seemless-immutable is also widely used immutable library, can we also support this?

cooperka commented 6 years ago

Sure, I'd happily accept a PR to support seamless-immutable!

The offending line of code is at https://github.com/cooperka/react-native-immutable-list-view/blob/master@{2017-12-04}/src/utils.js#L63, because seamless doesn't implement the isEmpty method.

In lieu of a PR, you could work around this yourself by doing something like the following, as an example:

import lodash from 'lodash';
import Immutable from 'seamless-immutable';

myObject = Immutable([1, 2, 3]);
myObject.isEmpty = lodash.isEmpty.bind(null, myObject);

or go even further and define it automatically for your app (note this example is untested):

import lodash from 'lodash';
import Immutable from 'seamless-immutable';

const originalImmutable = Immutable;
const customImmutable = (object) => {
  immutableObject = originalImmutable(object);
  immutableObject.isEmpty = lodash.isEmpty.bind(null, myObject);
  return immutableObject;
};

export default customImmutable;
cooperka commented 6 years ago

As a follow-up question, the point of seamless-immutable is so you don't need to use libraries like immutable-list-view; why not use a regular ListView?

cooperka commented 6 years ago

Closing due to inactivity.