Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Redux to Mobx #118

Draft
wants to merge 37 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
12bd63a
Add mobx dependency
ewc340 Jun 17, 2021
0d82ab9
Add mobx store skeleton
ewc340 Jun 17, 2021
b78ece7
Remove mobx-react-lite and add mobx-react
ewc340 Jun 17, 2021
bb59063
Add RootStore context and hook
ewc340 Jun 17, 2021
01f880e
Add Dummy component
ewc340 Jun 17, 2021
fbe7282
Include bootstrap updates with mobx migration (#119)
lancejackson Jun 24, 2021
4464f95
Mostly done with converting the reducers
HaileyJang Jun 24, 2021
de8acc1
add fieldStore observable
lancejackson Jun 24, 2021
c498f9b
fix errors
HaileyJang Jul 1, 2021
0242a7e
Merge dev and fix conflicts
ewc340 Jul 1, 2021
aa6425a
Merge branch 'migrate-redux-to-mobx' of https://github.com/pioneers/d…
HaileyJang Jul 1, 2021
2e8e5be
remove all statesprop and dispatch to mobx action functions
HaileyJang Jul 8, 2021
7911573
Commiting to update with dev
HaileyJang Jul 22, 2021
f0f2fe6
Merge branch 'dev' into migrate-redux-to-mobx
HaileyJang Jul 22, 2021
050d65b
Merge branch 'dev' into migrate-redux-to-mobx
HaileyJang Jul 22, 2021
06e216b
Up to what we have. Almost done?
HaileyJang Jul 22, 2021
c228829
Fixing dispatch and getting rid of unnecessary observers
HaileyJang Aug 4, 2021
de6d0bf
Changed everything to boxes. Started working on Peripherals
HaileyJang Aug 6, 2021
c8db2eb
Work on peripheral
HaileyJang Aug 12, 2021
69ecd52
Start on sagas
HaileyJang Aug 19, 2021
20fb3c8
Almost done with editor. Continue working on sftp
HaileyJang Aug 19, 2021
c585644
Keep editing peripheral
HaileyJang Aug 26, 2021
cf7efce
Done with peripherals?
HaileyJang Aug 28, 2021
31943bc
Add sleep function and lint/refactor editor
ewc340 Aug 28, 2021
ebfc803
Lint info store
ewc340 Aug 28, 2021
3c7cb90
Upload 1st draft of transferStudentCode
ewc340 Aug 28, 2021
777494b
Fix merge conflicts
ewc340 Nov 6, 2021
1492bce
Fix observable value in ConsoleStore
ewc340 Nov 6, 2021
6f32b2f
Update store utils
ewc340 Nov 6, 2021
151e111
Refactor and lint stores
ewc340 Nov 6, 2021
c9e5cee
Refactor editor and gamepads, add transferFile to utils
ewc340 Dec 23, 2021
04aa03f
Make ipc channels consts for better search use and robustness
ewc340 Jan 6, 2022
d1b8221
Move utils to separate folders and add Task concept
ewc340 Feb 3, 2022
75739a7
Some store updates
ewc340 Feb 3, 2022
52ead4e
Component updates
ewc340 Feb 3, 2022
4377929
Move editor components to new editor folder
ewc340 Feb 24, 2022
eb0acd1
Small tweaks
ewc340 Feb 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@
"json-loader": "0.5.7",
"keymirror": "0.1.1",
"lodash": ">=4.17.21",
"mobx": "^6.3.2",
"mobx-react": "^7.2.0",
"mousetrap": "1.6.1",
"numeral": "2.0.6",
"object-assign": "4.1.1",
Expand Down
10 changes: 10 additions & 0 deletions renderer/components/Dummy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Observer } from 'mobx-react';
import React from 'react';
import { useStores } from '../hooks';

// Use as an example of how to use the useStores hook - will delete later
export const Dummy = () => {
const { console } = useStores();

return <Observer>{() => <div>{console.consoleUnread}</div>}</Observer>
}
1 change: 1 addition & 0 deletions renderer/contexts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { storesContext } from './stores';
4 changes: 4 additions & 0 deletions renderer/contexts/stores.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import React from 'react';
import { RootStore } from '../stores';

export const storesContext = React.createContext(RootStore);
1 change: 1 addition & 0 deletions renderer/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { useStores } from './useStores';
4 changes: 4 additions & 0 deletions renderer/hooks/useStores.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import React from 'react';
import { storesContext } from '../contexts';

export const useStores = () => React.useContext(storesContext);
30 changes: 30 additions & 0 deletions renderer/stores/console.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { makeAutoObservable } from 'mobx';
import { RootStore } from './root';

export class ConsoleStore {
rootStore: typeof RootStore;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a better way to declare the type of RootStore but we'll just leave it like this for now.


showConsole = false;
consoleData: string[] = [];
disableScroll = false;
consoleUnread = false;

constructor(rootStore: typeof RootStore) {
makeAutoObservable(this);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeAutoObservable will automatically make fields defined in the class observable

this.rootStore = rootStore;
}

updateConsole = (value: string[]) => {
this.consoleData = [...this.consoleData, ...value];
this.consoleUnread = !this.consoleUnread;
};

clearConsole = () => {
this.consoleData = [];
};

toggleConsole = () => {
this.showConsole = !this.showConsole;
this.consoleUnread = false;
};
}
1 change: 1 addition & 0 deletions renderer/stores/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { RootStore } from './root';
13 changes: 13 additions & 0 deletions renderer/stores/root.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ConsoleStore } from './console';
// Make sure store imports are in alphabetical order

class RootStore_ {
console: ConsoleStore;

constructor() {
this.console = new ConsoleStore(this);
/** Initialize more stores here (try to keep it in alphabetical order) */
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After defining a Store, make sure to create an instance of it in the RootStore here.

}
}

export const RootStore = new RootStore_();
17 changes: 17 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6302,6 +6302,23 @@ mkdirp@^1.0.4:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==

mobx-react-lite@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/mobx-react-lite/-/mobx-react-lite-3.2.0.tgz#331d7365a6b053378dfe9c087315b4e41c5df69f"
integrity sha512-q5+UHIqYCOpBoFm/PElDuOhbcatvTllgRp3M1s+Hp5j0Z6XNgDbgqxawJ0ZAUEyKM8X1zs70PCuhAIzX1f4Q/g==

mobx-react@^7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/mobx-react/-/mobx-react-7.2.0.tgz#241e925e963bb83a31d269f65f9f379e37ecbaeb"
integrity sha512-KHUjZ3HBmZlNnPd1M82jcdVsQRDlfym38zJhZEs33VxyVQTvL77hODCArq6+C1P1k/6erEeo2R7rpE7ZeOL7dg==
dependencies:
mobx-react-lite "^3.2.0"

mobx@^6.3.2:
version "6.3.2"
resolved "https://registry.yarnpkg.com/mobx/-/mobx-6.3.2.tgz#125590961f702a572c139ab69392bea416d2e51b"
integrity sha512-xGPM9dIE1qkK9Nrhevp0gzpsmELKU4MFUJRORW/jqxVFIHHWIoQrjDjL8vkwoJYY3C2CeVJqgvl38hgKTalTWg==

[email protected]:
version "5.0.0"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-5.0.0.tgz#cccac988b0bc5477119cba0e43de7af6d6ad8f4e"
Expand Down