Skip to content

Commit

Permalink
fix: header & footer configuration assertion failure
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekTree0101 committed Apr 30, 2024
1 parent 3ba2d94 commit eb6725a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Sources/KarrotListKit/Section.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ extension Section {
@discardableResult
public func willDisplayHeader(_ handler: @escaping (WillDisplayEvent.EventContext) -> Void) -> Self {
var copy = self
if header == nil {
assertionFailure("Please declare the header first using [withHeader]")
}
copy.header = header?.willDisplay(handler)
return copy
}
Expand All @@ -186,6 +189,9 @@ extension Section {
@discardableResult
public func willDisplayFooter(_ handler: @escaping (WillDisplayEvent.EventContext) -> Void) -> Self {
var copy = self
if footer == nil {
assertionFailure("Please declare the footer first using [withFooter]")
}
copy.footer = footer?.willDisplay(handler)
return copy
}
Expand All @@ -196,6 +202,9 @@ extension Section {
/// - handler: The callback handler when the header is removed from the screen.
public func didEndDisplayHeader(_ handler: @escaping (DidEndDisplayingEvent.EventContext) -> Void) -> Self {
var copy = self
if header == nil {
assertionFailure("Please declare the header first using [withHeader]")
}
copy.header = header?.didEndDisplaying(handler)
return copy
}
Expand All @@ -206,6 +215,9 @@ extension Section {
/// - handler: The callback handler when the footer is removed from the screen.
public func didEndDisplayFooter(_ handler: @escaping (DidEndDisplayingEvent.EventContext) -> Void) -> Self {
var copy = self
if footer == nil {
assertionFailure("Please declare the footer first using [withFooter]")
}
copy.footer = footer?.didEndDisplaying(handler)
return copy
}
Expand Down

0 comments on commit eb6725a

Please sign in to comment.