Tama.Switch
It can be used both for Component View swapping and as a part of any JSX element.
function SwitchComponent(this: Tama.Component) {
const switcher = new Tama.Switch({
banned: <span>Bannedspan>,
pending: <span>Pendingspan>,
default: <span>Loading...span>
})
switcher.set("banned") // renders `Banned`.
switcher.set("pending") // renders `Pending`.
switcher.set("default") // renders `Loading...`.
switcher.sets(this.view)
return switcher.current.value
}
In case of being part of JSX, you should connect WebInflator.Switch.
const inflator = new WebInflator
inflator.adapters.add(SwitchWebInflator)
async function UserProfile() {
const userStatusSwitch = new Tama.Switch({
banned: <Status color="red">BannedStatus>,
pending: <Status color="yellow">PendingStatus>,
default: <Status color="green">ActiveStatus>
})
const user = await requestCurrentUser()
user.status.sets(userStatusSwitch)
return (
<div>
...
<div>Status: {userStatusSwitch}div>
...
div>
)
}