Giter Club home page Giter Club logo

Comments (4)

shaps80 avatar shaps80 commented on June 22, 2024

Hmm the demo app even adds removes sections without issue. Which wouldn’t be possible if the updateDelegate wasn’t set.

from composed.

JosephDuffy avatar JosephDuffy commented on June 22, 2024

Hmm the demo app even adds removes sections without issue. Which wouldn’t be possible if the updateDelegate wasn’t set.

Looking at the demo the delegate is set to an instance of SectionProviderMapping but I can't find where that's done.

I think I got confused about what it was embedded in. For example I have:

  • ComposedSectionProvider
    • ComposedSectionProvider
      • ComposedSectionProvider
        • SingleElementSection
        • SegmentedSectionProvider
          • Section

Changes made to the Section are not propagated and the delegate is nil, maybe this is actually an issue with SegmentedSectionProvider.

Edit

Making PeopleComposedSectionProvider a SegmentedSectionProvider and updating the insert to:

    var newIndex = 0

    func append() {
        append(peopleSection())
        self.currentIndex = newIndex
        newIndex += 1
    }

causes new inserts to not be shown after inserting a second section. A breakpoint at https://github.com/composed-swift/Composed-Demo/blob/master/Composed-Demo/Sections/PeopleSection+Editing.swift#L37 shows that updateDelegate is nil.

I can't figure out exactly how it should work but here's a test that I think should pass but doesn't:

import Quick
import Nimble

@testable import Composed

final class SegmentedSectionProvider_Spec: QuickSpec {

    override func spec() {
        describe("SegmentedSectionProvider") {
            var global: SegmentedSectionProvider!
            var mapping: SectionProviderMapping!
            var child1: ComposedSectionProvider!
            var child2: ArraySection<String>!

            beforeEach {
                global = SegmentedSectionProvider()
                mapping = SectionProviderMapping(provider: global)

                child1 = ComposedSectionProvider()
                    let child1a = ArraySection<String>()
                    let child1b = ArraySection<String>()
                child2 = ArraySection<String>()

                global.append(child1)
                global.append(child2)

                child1.append(child1a)
                child1.append(child1b)
            }

            context("after changing the `currentIndex") {
                beforeEach {
                    global.currentIndex = 1
                }

                it("should unset the delegate of the previous child") {
                    expect(child1.updateDelegate).to(beNil())
                }

                it("should set the delegate of the current child") {
                    expect(child2.updateDelegate).toNot(beNil()) // Fails
                }
            }

            context("without changing the `currentIndex`") {
                it("should set the delegate") {
                    expect(child1.updateDelegate).toNot(beNil()) // Fails
                }

                it("should not set the delegate of children") {
                    expect(child2.updateDelegate).to(beNil())
                }

            }
        }
    }

}

from composed.

shaps80 avatar shaps80 commented on June 22, 2024

I will review this soon and get back to you.

from composed.

shaps80 avatar shaps80 commented on June 22, 2024

This has been resolved and included in release v1.0.3

from composed.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.