PowerHorse Engine
    Preparing search index...

    Variable createSwitchConst

    createSwitch: <T = Instance>(
        Condition: unknown,
        Truthy?: (props?: unknown, children?: unknown) => Instance,
        Falsy?: (props?: unknown, children?: unknown) => Instance,
    ) => SwitchStatementReturn<T> = createSwitchInternal

    Type Declaration

      • <T = Instance>(
            Condition: unknown,
            Truthy?: (props?: unknown, children?: unknown) => Instance,
            Falsy?: (props?: unknown, children?: unknown) => Instance,
        ): SwitchStatementReturn<T>
      • Type Parameters

        • T = Instance

        Parameters

        • Condition: unknown

          A State

        • OptionalTruthy: (props?: unknown, children?: unknown) => Instance

          Optional shorthand for if Condition is true.

        • OptionalFalsy: (props?: unknown, children?: unknown) => Instance

          Optional shorthand for if Condition is false.

        Returns SwitchStatementReturn<T>

        SwitchStatementReturn, Can be called and used as a State and/or be a chainable object that contains .Case and .Default.

        e.g. createSwitch(State).Case(true, ...).Case(false, ...).Case(1, ...)

        Cases can also use functions that expect a boolean to be returned to specify if the condition is met. The Condition value will be passed as the first param.

        e.g. createSwitch(State: boolean).Case((State: boolean) => State === true, ...) --> Whenever "State" is true, the Case will be rendered. e.g. createSwitch(State: number).Case((State: boolean) => State > 1, ...) --> Whenever "State" is more than 1, the Case will be rendered.

        For jsx:

        () => createElement(...)