Skip to content

Commit

Permalink
Merge pull request #57 from shipt/development
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
chaceburnette authored Apr 16, 2021
2 parents d97806a + f30077b commit fc3f82c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 28 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ generate_types: &generate_types
name: Generate Types
command: cd osmosis; yarn generateTypes



jobs:
test:
<<: *defaults
Expand Down Expand Up @@ -49,6 +47,9 @@ jobs:
- run:
name: Publish package
command: cd osmosis; npm publish --access public
- run:
name: Create Git Version Tag
command: "cd osmosis; PACKAGE_VERSION=$(cat package.json | grep \\\"version\\\" | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag v$PACKAGE_VERSION && git push --tags"

workflows:
version: 2.1
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## v1.1.0

* Removed deprecated class based container logic

## v1.0.2

* Added generated type declarations
Expand Down
2 changes: 1 addition & 1 deletion osmosis/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shipt/osmosis",
"version": "1.0.2",
"version": "1.1.0",
"description": "A lightweight state management library for React and React Native",
"keywords": ["react", "react native", "state management", "hooks", "state persistence", "shipt"],
"main": "dist/index.js",
Expand Down
7 changes: 3 additions & 4 deletions osmosis/src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { StoreProvider } from './storeProvider.js';
import { Container, setupStore } from './setupStore.js';
import { setupStore } from './setupStore.js';
import { usePersistedState, configureUsePersistedState } from './usePersistedState.js';

export { Container, setupStore, StoreProvider, usePersistedState, configureUsePersistedState };
export { setupStore, StoreProvider, usePersistedState, configureUsePersistedState };
export default {
Container,
setupStore,
StoreProvider,
usePersistedState,
configureUsePersistedState
};
};
29 changes: 8 additions & 21 deletions osmosis/src/setupStore.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,32 @@
import React, { createContext } from 'react';

class Container {
constructor() {
this.container = {
state: {}
};
}
}

/**
* @callback useCustomHook
* @returns {Object}
*/

/**
* @param {useCustomHook} useCustomHook
* @param {Object=} classContainer - Deprecated: classContainer support will be removed in a future release
* @returns {Object[]}
*/
const setupStore = (useCustomHook, classContainer) => {
const setupStore = useCustomHook => {
const StoreContext = createContext();
let store = { state: {} };
let storeRef = { state: {} };

const withStoreContext = WrappedComponent => props => {
let container = useCustomHook();
if (classContainer) {
classContainer.container = container;
} else {
for (let key in container) {
store[key] = container[key];
}
let store = useCustomHook();
for (let key in store) {
storeRef[key] = store[key];
}

return (
<StoreContext.Provider value={[container]}>
<StoreContext.Provider value={[store]}>
<WrappedComponent {...props} />
</StoreContext.Provider>
);
};

return [StoreContext, withStoreContext, store];
return [StoreContext, withStoreContext, storeRef];
};

export { Container, setupStore };
export { setupStore };

0 comments on commit fc3f82c

Please sign in to comment.