@glue42/glux
v0.0.1-alpha.1
Published
## Install the package
Downloads
4
Readme
Get started with Glux
Install the package
npm install --save @glue42/glux @glue42/desktop redux
Add the Glux reducer
Note that we expect a glue
key to be used for the Glux reducer
// reducers.js
import { createStore, combineReducers } from "redux";
import { glueReducer } from "@glue42/glux";
export const createRootReducer = () =>
combineReducers({
glue: glueReducer
});
Add the Glux middleware
// configureStore.js
import { applyMiddleware, createStore } from 'redux'
import { glueMiddleware } from '@glue42/glux'
import { createRootReducer } from './reducers'
const glueConfig = {
appManager: 'full',
windows: true,
logger: true
}
const middlewares = [
glueMiddleware(glueConfig)
]
export const configureStore = (initialState) {
const store = createStore(
createRootReducer(),
initialState,
applyMiddleware(...middlewares)
)
return store
}
Start using glue in idiomatic redux way via selectors and actions
import { actions, selectors} from '@glue42/glux';
const Applications = ({ startApplication, applications }) => (
<table>
{applications.map(application => (
<tr>
<td> {application.name} </td>
<td>
<button onClick={() => {startApplication(application)}}>
Start
</button>
</td>
</tr>
)}
</table>
)
export default connect(
state => ({
applications: selectors.getApplications(state)
}),
dispatch => ({ ...bindActionCreators(actions, dispatch) })
)(Applications)