redux-meshblu v4.5.1
redux-meshblu
Meshblu actions for Redux. Helps you include meshblu related actions in your redux applications.
Install
npm install redux-meshblu --saveSupported Actions
- getDevice
- search
- update
- updateDangerously
Actions
All actions are suffixed with the request state. Example: getDevice action has getDeviceRequest, getDeviceSuccess, getDeviceFailure
authenticate
Verify that a uuid & token are considered valid by Meshblu
Arguments
meshbluConfigconnection options with the following keys:protocolThe protocol to use when connecting to the server. (Defaulthttps)hostnameThe hostname of the Meshblu server to connect to. (Default:meshblu.octoblu.com)portThe port of the Meshblu server to connect to. (Default:443)uuidUUID of the device to authenticate with.tokenToken of the device to authenticate with.
getDevice
Returns all information (except the token) of a specific device or node.
Arguments
uuidMeshblu device uuidmeshbluConfigconnection options with the following keys:protocolThe protocol to use when connecting to the server. (Defaulthttps)hostnameThe hostname of the Meshblu server to connect to. (Default:meshblu.octoblu.com)portThe port of the Meshblu server to connect to. (Default:443)uuidUUID of the device to authenticate with.tokenToken of the device to authenticate with.
register
Register a new device with data properties specified by the caller
Arguments
bodydata object containing properties of the new device.meshbluConfigconnection options with the following keys:protocolThe protocol to use when connecting to the server. (Defaulthttps)hostnameThe hostname of the Meshblu server to connect to. (Default:meshblu.octoblu.com)portThe port of the Meshblu server to connect to. (Default:443)uuidUUID of the device to authenticate with.tokenToken of the device to authenticate with.
search
Search for Devices
Arguments
- options
querySearch for devices using any property defined on that device. Meshblu also supports MongoDB-style query operators:$in,$exists, etc.projectionallows you to retrieve only the data you want.
meshbluConfigconnection options with the following keys:protocolThe protocol to use when connecting to the server. (Defaulthttps)hostnameThe hostname of the Meshblu server to connect to. (Default:meshblu.octoblu.com)portThe port of the Meshblu server to connect to. (Default:443)uuidUUID of the device to authenticate with.tokenToken of the device to authenticate with.
update
Updates a node or device currently registered with Meshblu that you have access to update. You can pass any key/value pairs to update object. This does a diff only (Equivalent to using $set and PUT)
Arguments
uuidMeshblu device uuidbodyAn object containing the properties intended to updatemeshbluConfigconnection options with the following keys:protocolThe protocol to use when connecting to the server. (Defaulthttps)hostnameThe hostname of the Meshblu server to connect to. (Default:meshblu.octoblu.com)portThe port of the Meshblu server to connect to. (Default:443)uuidUUID of the device to authenticate with.tokenToken of the device to authenticate with.
updateDangerously
Updates a node or device currently registered with Meshblu that you have access to update. You can pass any key/value pairs to update object. PUT expects a complete representation of the device, so all omitted keys will be removed on save with the exception of the UUID. Allows the use of $set, $inc, $push, etc. operators as documented in the MongoDB API
Arguments
uuidMeshblu device uuidbodyAn object containing the properties intended to updatemeshbluConfigconnection options with the following keys:protocolThe protocol to use when connecting to the server. (Defaulthttps)hostnameThe hostname of the Meshblu server to connect to. (Default:meshblu.octoblu.com)portThe port of the Meshblu server to connect to. (Default:443)uuidUUID of the device to authenticate with.tokenToken of the device to authenticate with.
Usage
The code block below shows an implementation of the search action.
component.js
import _ from 'lodash'
import React, { PropTypes } from 'react'
import { search } from 'redux-meshblu'
import { connect } from 'react-redux'
import FlowList from '../components/FlowList'
import {getMeshbluConfig} from '../services/auth-service'
class FlowsIndex extends React.Component {
componentDidMount() {
const meshbluConfig = getMeshbluConfig()
const query = {
type: 'octoblu:flow',
owner: meshbluConfig.uuid,
}
this.props.dispatch(search({query}, meshbluConfig))
}
render() {
const { flows, error, fetching } = this.props
return (
<Page>
<Heading level={3}>My Flows</Heading>
<FlowList flows={flows} />
</Page>
)
}
}
const mapStateToProps = ({ flows }) => {
const { devices, error, fetching } = flows
return { flows: devices, error, fetching }
}reducer.js
import { searchActions } from 'redux-meshblu'
const { searchRequest, searchSuccess, searchFailure } = searchActions
const initialState = {
devices: null,
error: null,
fetching: false,
}
export default function types(state = initialState, action) {
switch (action.type) {
case searchRequest.getType():
return { ...state, fetching: true }
case searchSuccess.getType():
return { ...state, devices: action.payload, fetching: false }
case searchFailure.getType():
return { ...state, error: action.payload, fetching: false }
default:
return state
}
}Example
Roadmap
- claimDevice
- createSubscription
- deleteSubscription
- devices
- generateAndStoreToken
- listSubscriptions
- message
- removeTokenByQuery
- revokeToken
- unregister
- whoami
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago