A crucial type in the app is the CognitoStore
. There's only ever one instance of this type that lives throughout the life-cycle of the app. Everywhere in our app, a dev has access to this one instance through the sharedInstance
static stored property on the CognitoStore
.
Important to note is the init
function on this type. It sets everything up, most imporantly the userPool
stored property of type AWSCognitoIdentityUserPool
. This in turn will provide access to the AWSCognitoIdentityUser
that exists on the AWSCognitoIdentityUserPool
. This is done by calling currentUser()
on the AWSCognitoIdentityUserPool
instance.
We expose the AWSCognitoIdentityUser
in the form of a computed property named currentUser
.
Here's how accessing this currentUser
looks like throughout the app: