Comments (7)
It is already possible. DataProvider can be extended into something custom. Check the following file: https://github.com/Flipkart/recyclerlistview/blob/master/src/core/dependencies/DataProvider.ts
Inherit DataProvider and override getDataForIndex()
. Start using immutable collection instead of array. Let me know if you need further help.
from recyclerlistview.
Worked, thanks.
this data: any[]
stopped me. Maybe better to have an interface and then make existing DataProvider basic implementation.
from recyclerlistview.
@naqvitalha have one question.
I looked at the source to override.
recyclerlistview/src/core/dependencies/DataProvider.ts
Lines 30 to 32 in b7c23d2
To redefine the function, need to access the _data
, but it is private.
What about creating any[]
, any
types to interfaces in generics, abstract functions?
from recyclerlistview.
@black7375 Use getAllData
instead.
from recyclerlistview.
@wxsms
I asked because I couldn't write a data type like List<T>
because of the type of _data
(any[]
), but I solved the problem by creating it again exclude interface.
Like this.
export abstract class GenericDataProvider<T, K = keyof T> extends BaseDataProvider{
public rowHasChanged: (r1: T | any, r2: T | any) => boolean;
// In JS context make sure stable id is a string
public getStableId: (index: number) => string;
protected m_firstIndexToProcess: number = 0;
protected m_size: number = 0;
protected m_data: K | any = List<T>([]);
protected m_hasStableIds = false;
protected m_requiresDataChangeHandling = false;
constructor(rowHasChanged: (r1: T | any, r2: T | any) => boolean,
getStableId?: (index: number) => string) {
super(rowHasChanged, getStableId);
this.rowHasChanged = rowHasChanged;
if (getStableId) {
this.getStableId = getStableId;
this.m_hasStableIds = true;
} else {
this.getStableId = (index) => index.toString();
}
}
public abstract newInstance(
rowHasChanged: (r1: T, r2: T) => boolean,
getStableId?: (index: number) => string ): GenericDataProvider<T, K>;
public abstract getDataForIndex(index: number): T | undefined;
public abstract cloneWithRows(newData: K | any,
firstModifiedIndex?: number): DataProvider;
public getAllData(): K | any {
return this.m_data;
}
...
from recyclerlistview.
@punksta Hi, could you pls show your solution here? I've tried the solution provided by @naqvitalha , by it doesn't work. It just show a blank screen without any errors. Thank you in advance!
from recyclerlistview.
Never mind. found out that I have to override not only getDataForIndex
, but also newInstance
and cloneWithRows
. and should extends BaseDataProvider
, not DataProvider
. This is not frinedly enough 😢 . But anyway, works now.
from recyclerlistview.
Related Issues (20)
- forceNonDeterministicRendering is not working when using different View_Types
- The focused row index is different from onVisibleIndicesChanged HOT 1
- Support for multiple viewability config
- 🅱️ Horizontal List Bug (Layout Problem for height not updated correctly) HOT 1
- `testID` & `accessibilityLabel` properties are not supported on recyclerlistview and it's elements?
- numColumns BUG HOT 5
- can not hide the scroll bar HOT 1
- Internal length of list? HOT 1
- compile error
- Recycerlistview renderItem function is rendering half of the item
- How can i render kind of skeleton placeholder items instead of whitespaces/blank?
- TouchableHighlight object inside a RecyclerListView Losing Focus on fast key navigation with React Native TVOS
- How can I interact with the latest selected row?
- Glitch issue when use ScrollViewWithHeader with GridLayoutProvider HOT 1
- useBottomSheetDynamicSnapPoints is deprecated
- Somebody help me!!! /core/RecyclerListView.js: Property id of VariableDeclarator expected node to be of a type ["LVal"] but instead got "BooleanLiteral" HOT 2
- npm run build is failing HOT 3
- Web accessibility: focus order is wrong.
- contextProvider offset does not work in apps with StrictMode enabled
- New architecture support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recyclerlistview.