Actions

Actions

Actions provides factory methods for creating the actions to dispatch to the Redux store.

The Types member can be used to create your own reducer aware of @fantaptik/react-auth actions.

Important You only need to use an instance of Actions when creating your own reducer aware of the actions dispatched by this package. In that case you should not instantiate Actions yourself -- instead perform one of the following:

  1. Use the globally exported Actions instance; if you did not instantiate any Gob instances this is probably what you want:
import { Actions } from '@fantaptik/react-auth';
console.log( Actions.Types );
// Create your own reducer here and switch off of `Actions.Types`
  1. Create an instance of Gob and use the Actions property:
import { Gob } from '@fantaptik/react-auth';
const slice = new Gob( 'slice-name' );
console.log( slice.Actions.Types );
// Create your own reducer here and switch off of `slice.Actions.Types`
// NB: Your reducer should also check that `slice.Actions.matches( action ) === true`

See the Understanding Gobs tutorial for extended information.

Constructor

new Actions(id)

Source:
Parameters:
Name Type Description
id string

Unique identifier shared by a Gob.

Members

(readonly) Types :Object

Source:
Properties:
Name Type Description
Close string
Open string
Reject string
ResumeBegin string
ResumeEnd string

Types returns the action.type strings that this instance dispatches to the Redux store.

Type:
  • Object

Methods

Close() → {Object}

Source:

Creates the Close reducer action.

This action sets the reducer to guest.

Returns:
Type
Object

matches(action) → {boolean}

Source:

matches accepts an action object and returns true if it matches the action generators from this instance.

Note action.type is not checked as it is assumed the reducer will be checking that property.

Parameters:
Name Type Description
action Object

The Redux action.

Returns:
Type
boolean

Open(session, user, username) → {Object}

Source:

Creates the Open reducer action.

This action sets the reducer to authenticated; all SocketPlugin instances will attempt to connect() to the server.

Parameters:
Name Type Description
session string

The session-id value.

user Object

The opaque user object received when authenticating with the server.

username string

The username that was used to authenticate.

Returns:
Type
Object

Reject() → {Object}

Source:

Creates the Reject reducer action.

This action indicates a SocketPlugin attempted to verify itself with the server and was rejected. Sets the reducer to guest.

Returns:
Type
Object

ResumeBegin() → {Object}

Source:

Creates the ResumeBegin reducer action.

This action is dispatched prior to an HTTP-POST session resume attempt.

Returns:
Type
Object

ResumeEnd() → {Object}

Source:

Creates the ResumeEnd reducer action.

This action is dispatched after an HTTP-POST session resume attempt has completed.

Returns:
Type
Object