fueled / datasource Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Getting this issue while fetching framework using carthage.
My cartfile.
github "ReactiveCocoa/ReactiveCocoa" "5.0.0-alpha.6"
github "Vadim-Yelagin/DataSource"
Fetched version
github "Vadim-Yelagin/DataSource" "0.4"
There is a simple static tableview where it shows profile data. Since this data was not changing, it has used the StaticDataSource
.
final class ProfileInfoCardViewModel {
let dataSource: DataSource
let profileViewModel: ProfileViewModel
init(profileViewModel: ProfileViewModel) {
self.profileViewModel = profileViewModel
let user = profileViewModel.user.producer.skipNil()
let proxyDataSource = ProxyDataSource()
self.dataSource = proxyDataSource
proxyDataSource.innerDataSource <~ user.map { user in
if user.isLoggedInUser {
if user.userLikes ?? 0 > 0 {
items.append(ProfileInfoRatingCellViewModel(userLikes : user.userLikes ?? 0))
} else {
items.append(ProfileInfoNoRatingsYetCellViewModel())
}
items.append(ProfileInfoUpdateCellViewModel())
}
return StaticDataSource(items: items)
}
}
}
There is a new requirement to make this tableview dynamic. Upon a tap of a button, I need to insert/remove a cell from this tableview. So I opted to use the MutableDataSource
. Also I changed the dataSource
class variable from DataSource
type to ProxyDataSource
directly.
final class ProfileInfoCardViewModel {
let dataSource: ProxyDataSource
let profileViewModel: ProfileViewModel
init(profileViewModel: ProfileViewModel) {
self.profileViewModel = profileViewModel
let user = profileViewModel.user.producer.skipNil()
self.dataSource = ProxyDataSource()
self.dataSource.innerDataSource <~ user.map { user in
if user.isLoggedInUser {
if user.userLikes ?? 0 > 0 {
items.append(ProfileInfoRatingCellViewModel(userLikes : user.userLikes ?? 0))
} else {
items.append(ProfileInfoNoRatingsYetCellViewModel())
}
items.append(ProfileInfoUpdateCellViewModel())
}
return MutableDataSource(items)
}
}
func userTappedToggleButton(_ show: Bool) {
// do changes (insert/remove) to the inner mutable data source here
}
}
The data loads fine still. However I'm having trouble figuring out how to make changes to the inner data source (add/remove an item).
Hi,
In an old Swift 4 project which used this library, I had the following code.
let expanded = MutableProperty(false)
let dataSource = ProxyDataSource()
let s1 = StaticDataSource(items: [])
let s2 = StaticDataSource(items: [])
dataSource.innerDataSource <~ expanded.map { $0 ? s1 : s2 }
And it worked fine.
Recently I updated it to the latest version (1.0.1). Now I'm getting the following compile error.
Ambiguous reference to member 'map'
I checked the ReactiveSwift versions DataSource used in the old (3.0.1) and in the new version (6.0.1). The map
function is still the same. So I'm not sure why error is occurring now.
I am using Datasource for my collection view to populate data.. If the number of cells to be used are less than a said amount it works well, but if it is very large, say 30k. UI hangs and CPU overclocking is observed.
Code:
let optionsDataSource: MutableDataSource
self.optionsDataSource.replaceItems(with: Array(self.optionsCellModelForCurrentTask().prefix(100))) // Works well.. count is 100.
self.optionsDataSource.replaceItems(with: self.optionsCellModelForCurrentTask()) // CPU overclocking and memory leaks
self.optionsCellModelForCurrentTask() // count: 31000.
Any help would be highly appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.