This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createHook } from 'react-sweet-state' | |
| const makeSelectorsIntoHooks = (selectors, store) => ( | |
| Object.keys(selectors).reduce((accSelectors, selectorName) => { | |
| accSelectors[selectorName] = createHook(store, { | |
| selector: selectors[selectorName] | |
| }) | |
| return accSelectors | |
| }, {}) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createStore } from 'react-sweet-state' | |
| import actions from './visibilityFilter.actions' | |
| export const VisibilityFilters = { | |
| SHOW_ALL: 'SHOW_ALL', | |
| SHOW_COMPLETED: 'SHOW_COMPLETED', | |
| SHOW_ACTIVE: 'SHOW_ACTIVE' | |
| } | |
| const initialState = VisibilityFilters.SHOW_ALL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const visibilityFilterActions = { | |
| setVisibilityFilter: filter => ({ setState }) => { | |
| setState(() => filter) | |
| } | |
| } | |
| export default visibilityFilterActions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import makeSelectorsIntoHooks from '../utils' | |
| import visibilityFilterStore from '../visibilityFilter/visibilityFilter.store' | |
| const visibilityFilterSelectors = { | |
| useVisibilityFilterActions: null, | |
| useVisibilityFilter: visibilityFilter => visibilityFilter | |
| } | |
| export default makeSelectorsIntoHooks(visibilityFilterSelectors, visibilityFilterStore) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import todosSelectors from './todos/todos.selectors' | |
| import visibilityFilterSelectors from './visibilityFilter/visibilityFilter.selectors' | |
| const multiStoreSelectors = { | |
| useVisibleTodos: () => { | |
| const [visibilityFilter, visibilityFilterActions] = visibilityFilterSelectors.useVisibilityFilter() | |
| const [visibleTodos, todosActions] = todosSelectors.useVisibleTodos(visibilityFilter) | |
| return [visibleTodos, { ...visibilityFilterActions, ...todosActions }] | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| import todosSelectors from '../stores/todos/todos.selectors' | |
| const AddTodo = () => { | |
| let input | |
| const [, { addTodo }] = todosSelectors.useTodosActions() | |
| return ( | |
| <div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| import Link from '../components/Link' | |
| import visibilityFilterSelectors from '../stores/visibilityFilter/visibilityFilter.selectors' | |
| const FilterLink = ({ children, filter }) => { | |
| const [visibilityFilter, { setVisibilityFilter }] = visibilityFilterSelectors.useVisibilityFilter() | |
| return ( | |
| <Link | |
| active={filter === visibilityFilter} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| import TodoList from '../components/TodoList' | |
| import multiStoreSelectors from '../stores/multi-store.selectors' | |
| const VisibleTodoList = ({ children }) => { | |
| const [visibleTodos, { toggleTodo }] = multiStoreSelectors.useVisibleTodos() | |
| return ( | |
| <TodoList | |
| todos={visibleTodos} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dependencies { | |
| implementation fileTree(dir: 'libs', include: ['*.jar']) | |
| // TODO: Change to local Unity classes jar location | |
| compileOnly files('/Applications/Unity/Hub/Editor/2018.4.19f1/PlaybackEngines/AndroidPlayer/Variations/mono/Release/Classes/classes.jar') | |
| api 'androidx.appcompat:appcompat:1.1.0' | |
| implementation files('libs/gson-2.8.6.jar') | |
| testImplementation 'junit:junit:4.12' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| afterEvaluate { | |
| assembleDebug.finalizedBy(exportAARDebug) | |
| } | |
| task deleteOldAARDebug(type: Delete) { | |
| delete '../../UnityPluginExample/Assets/Plugins/Android/nativecalculations-debug.aar' | |
| } | |
| task exportAARDebug(type: Copy) { | |
| from('build/outputs/aar') |