Skip to content

Commit

Permalink
new sectionbindable
Browse files Browse the repository at this point in the history
  • Loading branch information
baveku committed Jan 22, 2022
1 parent 3e1b675 commit 280fe25
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Comier/Classes/AS+IGlistKit/COSectionController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@ import Foundation
import IGListDiffKit
import IGListKit
import AsyncDisplayKit
import RxSwift

public protocol SectionBindable: SectionViewmodelable {
associatedtype ViewModelType: ViewModel
}

/**
Binding ViewModel from ViewController to Section Controller
Inside Section Init:
`override init() {
super.init()
displayDelegate = self
}`
*/
public protocol SectionViewmodelable: AnyObject {
func bindRootViewModel()
Expand Down Expand Up @@ -51,6 +47,7 @@ public extension SectionBindable where Self: COSectionController {
}

open class COSectionController: ListSectionController, ASSectionController, ListSupplementaryViewSource, ASSupplementaryNodeSource, ListDisplayDelegate {
var isBinded = false
public override init() {
super.init()
if self is SectionViewmodelable {
Expand Down Expand Up @@ -125,7 +122,11 @@ open class COSectionController: ListSectionController, ASSectionController, List

public func listAdapter(_ listAdapter: ListAdapter, willDisplay sectionController: ListSectionController) {
if let self = self as? SectionViewmodelable {
self.bindRootViewModel()
if !isBinded {
isBinded = true
self.bindRootViewModel()
}
self.sectionWillDisplay(sectionController)
}
}

Expand Down

0 comments on commit 280fe25

Please sign in to comment.