JohnEstropia / CoreStore

Unleashing the real power of Core Data with the elegance and safety of Swift
MIT License
3.97k stars 255 forks source link

ListPublisher section name transformer not working #414

Closed joeljfischer closed 3 years ago

joeljfischer commented 3 years ago

Hi, I have a .sectionBy clause set up, but it appears that the name transformer isn't working.

listPublisher = CoreStoreDefaults.dataStack.publishList(
    From<Stopwatch>()
        .sectionBy(\.$isStarted, { (sectionName) -> String? in
            if sectionName == "1" {
                return "Running".localized()
            } else {
                return "Stopped".localized()
            }
        })
        .orderBy(.descending(\.$name))
)

Here, $.isStarted a boolean virtual property, but that all appears to be working correctly. I can breakpoint within the .sectionBy closure and it's running and returning the correct string, but 0 or 1 is still appearing as the section header of my list. Do I need to implement titleForHeader / viewForHeaderInSection? It says to do so under the ListMonitor documentation but not the list publisher documentation. If so, what would I access to see my transformed string?

JohnEstropia commented 3 years ago

@joeljfischer The titleForHeader / viewForHeaderInSection for DiffableDataSource adapters currently doesn't support the custom sectionIndex transformers, sorry about that. I'll try to rework the adapters in an update, but for now you have the following options to work around it: