Resettable

public protocol Resettable

Note that although this protocol is public, the reset method is intended only for internal use, and should not be invoked by host applications.

  • reset() Asynchronous

    Called when the client calls await Amplify.reset() during testing. When invoked, the plugin must release resources and reset shared state. Shortly after calling reset() on the plugin, the category and its associated plugins will be released. Immediately after returning, the plugin’s underlying system must be ready to instantiate a new plugin and configure it.

    This method is intended only for use by the Amplify system, and should not be invoked by host applications.

    Declaration

    Swift

    func reset() async

Available where Self: Plugin

  • reset() Default implementation, asynchronous

    Default Implementation

    A default conformance if the plugin has no reset logic

    Warning

    This conformance will take precedence over a non-async reset method in an async context. Thus, given a plugin like:

    class MyPlugin: Plugin {
        // Not invoked during `await Amplify.reset()`
        func reset() { ... }
    }
    

    The MyPlugin.reset() method will never be called during an invocation of await Amplify.reset(). Ensure plugin reset() methods are always declared async:

    class MyPlugin: Plugin {
        // Invoked during `await Amplify.reset()`
        func reset() async { ... }
    }
    

    As a best practice, always invoke reset through the Resettable protocol existential, rather than the concrete conforming type, especially in tests:

    func testReset() async {
        let resettable = plugin as Resettable
        await resettable.reset()
        // ... assert that the plugin state has been cleared
    }
    

    Declaration

    Swift

    func reset() async