๐ง Ionic + Angular +Ngrx
ํ ํ์ฌ์์ Ionic ์ํ๊ด๋ฆฌ๊ฐ ๋์ด์์ง ์์๋ค. ๊ทธ๋ฆฌํ์ฌ Ionic์ด Anuglar์ ๋ํ ์๋ฃ๊ฐ ๋ง์์ Angular๋ ์ํ๊ด๋ฆฌ๋ ์ด๋ป๊ฒ ํ๋๊ฐ๋ฅผ ์ฐพ์๋ณด๋ค, Ngrx๋ฅผ ์ฌ์ฉํ๊ณ ์์๋ค. ํ์ง๋ง ๋ฌด์จ์ด์ ์ธ์ง ํฌ๋กฌ ํ์ฅ์ redux-dev-tools์์ ์๋ฌด๊ฒ๋ ๋ณด์ด์ง ์๋๋ค... ๊ทธ๋์ ์๋ก์ด ๋ฐฉ๋ฒ์ ์ฐพ์๋ณด์๋ค.
๐ถ ionic-remote-devtool ์์ค๋ฅผ ๋ฐ์!
https://github.com/somq/ionic4-remote-devtool ์์ git clone ํ์ฌ ์์ค๋ฅผ ๋ฐ์
git clone https://github.com/somq/remotedev-server.git

๋ค์์ผ๋ก npm intall๋ฅผ ํด์ฃผ์

๐ Ionic ํ๋ก์ ํธ์ remotedev๋ฅผ ์ค์นํด์ฃผ์
npm install --save-dev remotedev
์ ์ค์น๋ฅผ ํตํ์ฌ ionic4-remote-devtool ๊ณผ ์ฐ๊ฒฐํ์ฌ ๋ณผ ์ ์๋ค.
๐ remote-devtools-connection-proxy.ts, remote-devtools-proxy.ts ์์ฑ
ionic ํ๋ก์ ํธ app ํด๋ ๋ฐ์ "remote-devtools-connection-proxy.ts,remote-devtools-proxy.ts"๋ฅผ ๋ง๋ค์ด์ฃผ์
remote-devtools-connection-proxy.ts
import { ReduxDevtoolsExtensionConnection } from '@ngrx/store-devtools/src/extension';
export class RemoteDevToolsConnectionProxy
implements ReduxDevtoolsExtensionConnection {
constructor(public remotedev: any, public instanceId: string) {}
init(state?: any): void {
//throw new Error('Method not implemented.');
}
error(anyErr: any): void {
//throw new Error('Method not implemented.');
}
subscribe(listener: (change: any) => void): any {
const listenerWrapper = (change: any) => {
listener(change);
};
this.remotedev.subscribe(listenerWrapper);
// Hack fix for commit/time-travelling etc. if the devtools are already open
setTimeout(() => listenerWrapper({ type: 'START' }));
}
unsubscribe(): any {
// HACK fix bug in @ngrx/store-devtools that calls this instead of returning
// a lambda that calls it when their Observable wrapper is unsubscribed.
return () => this.remotedev.unsubscribe(this.instanceId);
}
send(action: any, state: any): any {
// Never called
}
}
remote-devtools-proxy.ts
import { ReduxDevtoolsExtension, ReduxDevtoolsExtensionConnection, ReduxDevtoolsExtensionConfig } from '@ngrx/store-devtools/src/extension';
import { RemoteDevToolsConnectionProxy } from './remote-devtools-connection-proxy'
import { connect } from 'remotedev/lib/devTools';
export class RemoteDevToolsProxy implements ReduxDevtoolsExtension {
remotedev: any = null;
defaultOptions = {
realtime: true,
// Needs to match what you run `remotedev` command with and
// what you setup in remote devtools local connection settings
hostname: 'localhost',
port: 8000,
autoReconnect: true,
connectTimeout: 20000,
ackTimeout: 10000,
secure: true
};
constructor(defaultOptions: Object) {
this.defaultOptions = Object.assign(this.defaultOptions, defaultOptions);
}
connect(options: ReduxDevtoolsExtensionConfig): ReduxDevtoolsExtensionConnection {
const connectOptions = Object.assign(this.defaultOptions, options);
this.remotedev = connect(connectOptions);
const connectionProxy = new RemoteDevToolsConnectionProxy(
this.remotedev,
connectOptions.name
);
return connectionProxy;
}
send(action: any, state: any): any{
this.remotedev.send(action,state);
}
}
๐ remote ํ์ผ์ app.moudule์ ์ถ๊ฐํด์ฃผ์!
app.module.ts
import { RemoteDevToolsProxy } from './remote-devtools-proxy';
if (!window['devToolsExtension'] && !window['__REDUX_DEVTOOLS_EXTENSION__']) {
let remoteDevToolsProxy = new RemoteDevToolsProxy({
connectTimeout: 300000, // extend for pauses during debugging
ackTimeout: 120000, // extend for pauses during debugging
secure: false // dev only
});
window['devToolsExtension'] = remoteDevToolsProxy;
window['__REDUX_DEVTOOLS_EXTENSION__'] = remoteDevToolsProxy;
}
.
.
.
.
.
export class AppModule {}
๐คก remote-dev-tools๋ฅผ ์คํ์ํค์
remotedev --hostname=localhost --port=8000
๊ทธ๋ฌ๋ฉด ๋ธ๋ผ์ฐ์ ์์ localhost:8000๋ฅผ ๋์ด๋ณธ๋ค.
์๋์ ๊ฐ์ด ๋จ๋๊ฑธ ๋ณผ ์ ์๋ค.

๐บ ๊ฐ๋ฐ์ ๋๊ตฌ์์ ํฌํธํฌ์๋ฉ์ ์ํค์
์๋ ์ฌ์ง์ฒ๋ผ ํฌํธํฌ์๋ฉ์ ํตํด์ localhost:8000์ ํด์ฃผ๋ฉด ionic+angular์์ redux-dev-tools์ด ์ฌ์ฉ๊ฐ๋ฅํ๋ค.

'ionic' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| ๐ค ionic fcm background์์ ๋ฐ์ดํฐ ๋ฐ๊ธฐ (1) | 2022.03.20 |
|---|---|
| Ionic Speech Recognition (0) | 2022.01.01 |
| ๐Ionic Android APK ์ถ์ถ (0) | 2021.10.01 |
| ๐ณโ๐Proxy ์ธํ (0) | 2021.09.07 |
| ionic + angular ์ธํ (2) | 2021.07.31 |
๋๊ธ