diff --git a/strada/src/main/kotlin/dev/hotwire/strada/BridgeComponent.kt b/strada/src/main/kotlin/dev/hotwire/strada/BridgeComponent.kt index 6afc01e..ece92ee 100644 --- a/strada/src/main/kotlin/dev/hotwire/strada/BridgeComponent.kt +++ b/strada/src/main/kotlin/dev/hotwire/strada/BridgeComponent.kt @@ -6,19 +6,6 @@ abstract class BridgeComponent( ) { private val receivedMessages = hashMapOf() - internal fun didReceive(message: Message) { - receivedMessages[message.event] = message - onReceive(message) - } - - internal fun didStart() { - onStart() - } - - internal fun didStop() { - onStop() - } - /** * Returns the last received message for a given `event`, if available. */ @@ -32,6 +19,38 @@ abstract class BridgeComponent( */ abstract fun onReceive(message: Message) + /** + * This passes a received message to onReceive(message), caching it + * for use with replyTo(event) and receivedMessageFor(event). + * + * NOTE: This should not be called directly from within a component, + * but is available to use for testing. + */ + fun didReceive(message: Message) { + receivedMessages[message.event] = message + onReceive(message) + } + + /** + * This passes the start lifecycle event to onStart(). + * + * NOTE: This should not be called directly from within a component, + * but is available to use for testing. + */ + fun didStart() { + onStart() + } + + /** + * This passes the stop lifecycle event to onStop(). + * + * NOTE: This should not be called directly from within a component, + * but is available to use for testing. + */ + fun didStop() { + onStop() + } + /** * Called when the component's destination starts (and is active) * based on its lifecycle events. You can use this as an opportunity