WIP!
npm i redux-scorm -S
yarn add redux-scorm
import { combineReducers, createStore, applyMiddleware } from 'redux';
import { reducer as scorm, middleware as scormMiddleware } from 'redux-scorm';
// add the reducer
const reducer = combineReducers({
scorm,
// other reducers...
});
// add the middleware
const middleware = applyMiddleware(
scormMiddleware({ scorm: window.API_1484_11 }),
// other middleware...
);
// create the SCORMified store!
const store = createStore(reducer, middleware);
import { connect } from 'react-redux';
import { setValue } from 'redux-scorm';
let locationComponent = ({ scorm, setValue }) => (
<div>
<p>Current Location: {scorm.model['cmi.location']}</p>
<p onClick={() => setValue('cmi.location', Number(scorm.model['cmi.location'] + 1))}>Next Page</p>
</div>
);
function mapStateToProps(state) {
return {
scorm: state.scorm
};
}
const mapDispatchToProps = {
setValue
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(locationComponent);
initialize()
reinitialize()
terminate()
getValue(element)
setValue(element, value)
commit()
getLastError()
getErrorString(errorCode)
getDiagnostic(errorCode)