Comments (3)
你好,我有点不太确定我有没有明白你的意思,你是指你的loadData函数也就是getAreaDevices需要除了page以外的参数该怎么传递吗?这样的话直接在viewmodel中维护一个变量就行了,loaddata中直接使用即可, 简单例子如下:
class viewModel() : ViewModel() {
var param1 = "hhhh"
val pager = easyPager {
return@easyPager brandIndexService.getBrandIndex(
param1,
it
)
}
}
如果不是这个意思麻烦你描述的稍微再详细一点,谢谢!
from compose-paginglist.
你好,我有点不太确定我有没有明白你的意思,你是指你的loadData函数也就是getAreaDevices需要除了page以外的参数该怎么传递吗?这样的话直接在viewmodel中维护一个变量就行了,loaddata中直接使用即可, 简单例子如下:
class viewModel() : ViewModel() { var param1 = "hhhh" val pager = easyPager { return@easyPager brandIndexService.getBrandIndex( param1, it ) } }
如果不是这个意思麻烦你描述的稍微再详细一点,谢谢!
没错!
我现在就是这样,在函数外面维护一个变量。
但是这样有时会出现问题,例如,这个 loadData 同时有 3 个地方调用,这时这个外部的变量就可能因为并发问题,导致读取的时候出现不确定性。
from compose-paginglist.
你这个情况确实我确实没考虑到,因为一般一个分页列表的loaddata方法只会服务于该分页列表,触发时机由PagingSource控制。官方的Paging使用指南中也是单独调用的,多处调用的场景是什么?考虑抽离一个单独的loaddata方法仅服务于分页列表?如果实在存在同时调用的并发情况,可能只能考虑采用并发安全的类型来处理变量。
from compose-paginglist.
Related Issues (3)
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 compose-paginglist.