Skip to content

Improve BoardProducer transmission mechanism

Latest
Compare
Choose a tag to compare
@congncif congncif released this 01 Oct 08:27
· 75 commits to master since this release

To avoid reference retaining, BoardProducer will be converted to struct before pass around

  • Update ProducerBox struct for passing BoardProducer around
// To transform a producer to Box
producer.boxed
  • Update LauncherComponent: convert Component to struct before forward to Plugin

You need to migrate accessing to mainProducer in ModulePlugin:

// Boardy 1.33.x, you need use [unowned mainProducer]

public struct HomeModulePlugin: ModulePlugin {
...
    public func apply(for main: MainComponent) {
            let mainProducer = main.producer
    
            mainProducer.registerBoard(identifier) { [unowned mainProducer] identifier in
                 // Start using mainProducer
            }
    }
}

// Boardy 1.34.x

public struct HomeModulePlugin: ModulePlugin {
...
    public func apply(for main: MainComponent) {
            let mainProducer = main.producer
    
            mainProducer.registerBoard(identifier) { identifier in
                 // Start using mainProducer directly
            }
    }
}