Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
feat(examples): improve examples
Browse files Browse the repository at this point in the history
* update deps
* refactor some modules
  • Loading branch information
fostyfost committed Feb 20, 2022
1 parent d4c111a commit 9d409f8
Show file tree
Hide file tree
Showing 133 changed files with 937 additions and 3,697 deletions.
2,490 changes: 484 additions & 2,006 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/mitt-npm-2.1.0-77f3c96db4-5b0f698cbf.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 7 additions & 2 deletions examples/example-next-gip/eggs/aviasales/events.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import mitt from 'mitt'

export const AviasalesEventEmitter = mitt()

export enum AviasalesEvent {
GET_TICKETS = 'aviasales/GET_TICKETS',
CHANGE_STOPS = 'aviasales/CHANGE_STOPS',
Expand All @@ -12,6 +10,13 @@ export enum ChangeStopsMassive {
UNCHECK_ALL = 'UNCHECK_ALL',
}

type MittEvents = {
[AviasalesEvent.GET_TICKETS]: string | undefined
[AviasalesEvent.CHANGE_STOPS]: number | ChangeStopsMassive
}

export const AviasalesEventEmitter = mitt<MittEvents>()

export const AviasalesPublicAction = {
getTickets() {
AviasalesEventEmitter.emit(AviasalesEvent.GET_TICKETS, AviasalesEvent.GET_TICKETS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getTickets } from '@/eggs/aviasales/saga/get-tickets'
import { isAllTicketLoadedSelector } from '@/eggs/aviasales/selectors'
import { StoreActionType } from '@/store/action-types'

type ChannelPayload = string
type ChannelPayload = string | undefined

const subscribe: Subscribe<ChannelPayload> = emitter => {
const handler: Handler<ChannelPayload> = payload => {
Expand Down
2 changes: 2 additions & 0 deletions examples/example-next-gip/eggs/count/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Egg } from '@redux-eggs/core'

import { skipHydration } from '@/eggs/count/middlewares'
import { COUNT_REDUCER_KEY, countReducer } from '@/eggs/count/reducer'
import { countWatcher } from '@/eggs/count/saga'
import type { AppStore } from '@/store'
Expand All @@ -10,6 +11,7 @@ export const getCountEgg = (): Egg<AppStore> => {
reducersMap: {
[COUNT_REDUCER_KEY]: countReducer,
},
middlewares: [skipHydration],
sagas: [countWatcher],
}
}
13 changes: 13 additions & 0 deletions examples/example-next-gip/eggs/count/middlewares.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Middleware } from 'redux'

import { COUNT_REDUCER_KEY } from '@/eggs/count/reducer'
import { countSelector } from '@/eggs/count/selectors'
import { StoreActionType } from '@/store/action-types'

export const skipHydration: Middleware = store => next => action => {
if (action.type === StoreActionType.HYDRATE && countSelector(store.getState())) {
delete action.payload[COUNT_REDUCER_KEY]
}

next(action)
}
7 changes: 0 additions & 7 deletions examples/example-next-gip/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
* @type {import('next').NextConfig}
*/
const nextConfig = {
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
// ignoreBuildErrors: true,
},
images: {
domains: ['pics.avs.io'],
},
Expand Down
42 changes: 21 additions & 21 deletions examples/example-next-gip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
"@redux-saga/symbols": "1.1.2",
"clsx": "1.1.1",
"cross-env": "7.0.3",
"dayjs": "1.10.4",
"immer": "9.0.6",
"mitt": "2.1.0",
"nanoid": "3.1.30",
"next": "12.0.8",
"dayjs": "1.10.7",
"immer": "9.0.12",
"mitt": "3.0.0",
"nanoid": "3.3.1",
"next": "12.1.0",
"nprogress": "0.2.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-intersection-observer": "8.32.0",
"react-intersection-observer": "8.33.1",
"react-redux": "7.2.6",
"redux": "4.1.2",
"redux-devtools-extension": "2.13.9",
Expand All @@ -52,23 +52,23 @@
"reselect": "4.1.5"
},
"devDependencies": {
"@jest/types": "27.4.2",
"@next/bundle-analyzer": "12.0.8",
"@types/jest": "27.0.3",
"@types/node": "16.11.11",
"@jest/types": "27.5.1",
"@next/bundle-analyzer": "12.1.0",
"@types/jest": "27.4.0",
"@types/node": "17.0.18",
"@types/nprogress": "0.2.0",
"@types/react": "17.0.37",
"@types/react": "17.0.39",
"@types/react-dom": "17.0.11",
"@types/react-redux": "7.1.20",
"@types/redux-logger": "3.0.8",
"eslint": "7.32.0",
"eslint-config-next": "12.0.8",
"jest": "27.4.2",
"redux-saga-test-plan": "4.0.3",
"sass": "1.35.2",
"styled-jsx": "4.0.0",
"ts-jest": "27.1.0",
"@types/react-redux": "7.1.22",
"@types/redux-logger": "3.0.9",
"eslint": "8.9.0",
"eslint-config-next": "12.1.0",
"jest": "27.5.1",
"redux-saga-test-plan": "4.0.4",
"sass": "1.49.8",
"styled-jsx": "5.0.0",
"ts-jest": "27.1.3",
"tslib": "2.3.1",
"typescript": "4.5.2"
"typescript": "4.5.5"
}
}
10 changes: 7 additions & 3 deletions examples/example-next-gip/pages/posts/gip/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ interface HeadingProps {

type Props = HeadingProps & { errorCode?: number }

const postTitleSelector = createSelector(isActivePostLoading, activePostSelector, (isLoading, activePost): string =>
isLoading ? 'Post is loading ...' : `${activePost?.title || 'Empty title'}`,
)
const postTitleSelector = createSelector(isActivePostLoading, activePostSelector, (isLoading, activePost): string => {
if (isLoading) {
return 'Post is loading ...'
}

return `${activePost?.title || 'Empty title'}`
})

const Heading: FC<HeadingProps> = ({ title }) => {
const postTitle = useSelector(postTitleSelector)
Expand Down
9 changes: 7 additions & 2 deletions examples/example-next-rtk/eggs/aviasales/events.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import mitt from 'mitt'

export const AviasalesEventEmitter = mitt()

export enum AviasalesEvent {
GET_TICKETS = 'aviasales/GET_TICKETS',
CHANGE_STOPS = 'aviasales/CHANGE_STOPS',
Expand All @@ -12,6 +10,13 @@ export enum ChangeStopsMassive {
UNCHECK_ALL = 'UNCHECK_ALL',
}

type MittEvents = {
[AviasalesEvent.GET_TICKETS]: string | undefined
[AviasalesEvent.CHANGE_STOPS]: number | ChangeStopsMassive
}

export const AviasalesEventEmitter = mitt<MittEvents>()

export const AviasalesPublicAction = {
getTickets() {
AviasalesEventEmitter.emit(AviasalesEvent.GET_TICKETS, AviasalesEvent.GET_TICKETS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { isAllTicketLoadedSelector } from '@/eggs/aviasales/selectors'
import { AviasalesReducerAction } from '@/eggs/aviasales/slice'
import { StoreActionType } from '@/store/action-types'

type ChannelPayload = string
type ChannelPayload = string | undefined

const subscribe: Subscribe<ChannelPayload> = emitter => {
const handler: Handler<ChannelPayload> = payload => {
Expand Down
13 changes: 13 additions & 0 deletions examples/example-next-rtk/eggs/count/middlewares.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Middleware } from '@reduxjs/toolkit'

import { countSelector } from '@/eggs/count/selectors'
import { COUNT_SLICE } from '@/eggs/count/slice'
import { StoreActionType } from '@/store/action-types'

export const skipHydration: Middleware = store => next => action => {
if (action.type === StoreActionType.HYDRATE && countSelector(store.getState())) {
delete action.payload[COUNT_SLICE]
}

next(action)
}
7 changes: 0 additions & 7 deletions examples/example-next-rtk/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
* @type {import('next').NextConfig}
*/
const nextConfig = {
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
// ignoreBuildErrors: true,
},
images: {
domains: ['pics.avs.io'],
},
Expand Down
42 changes: 21 additions & 21 deletions examples/example-next-rtk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,40 @@
"@redux-eggs/saga-extension": "workspace:*",
"@redux-saga/is": "1.1.2",
"@redux-saga/symbols": "1.1.2",
"@reduxjs/toolkit": "1.6.2",
"@reduxjs/toolkit": "1.7.2",
"clsx": "1.1.1",
"cross-env": "7.0.3",
"dayjs": "1.10.4",
"mitt": "2.1.0",
"next": "12.0.8",
"dayjs": "1.10.7",
"mitt": "3.0.0",
"next": "12.1.0",
"nprogress": "0.2.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-intersection-observer": "8.32.0",
"react-intersection-observer": "8.33.1",
"react-redux": "7.2.6",
"redux-logger": "3.0.6",
"redux-saga": "1.1.3",
"typed-redux-saga": "1.3.1"
"typed-redux-saga": "1.4.0"
},
"devDependencies": {
"@jambit/eslint-plugin-typed-redux-saga": "0.4.0",
"@jest/types": "27.4.2",
"@next/bundle-analyzer": "12.0.8",
"@types/jest": "27.0.3",
"@types/node": "16.11.11",
"@jest/types": "27.5.1",
"@next/bundle-analyzer": "12.1.0",
"@types/jest": "27.4.0",
"@types/node": "17.0.18",
"@types/nprogress": "0.2.0",
"@types/react": "17.0.37",
"@types/react": "17.0.39",
"@types/react-dom": "17.0.11",
"@types/react-redux": "7.1.20",
"@types/redux-logger": "3.0.8",
"eslint": "7.32.0",
"eslint-config-next": "12.0.8",
"jest": "27.4.2",
"redux-saga-test-plan": "4.0.3",
"sass": "1.35.2",
"styled-jsx": "4.0.0",
"ts-jest": "27.1.0",
"@types/react-redux": "7.1.22",
"@types/redux-logger": "3.0.9",
"eslint": "8.9.0",
"eslint-config-next": "12.1.0",
"jest": "27.5.1",
"redux-saga-test-plan": "4.0.4",
"sass": "1.49.8",
"styled-jsx": "5.0.0",
"ts-jest": "27.1.3",
"tslib": "2.3.1",
"typescript": "4.5.2"
"typescript": "4.5.5"
}
}
10 changes: 7 additions & 3 deletions examples/example-next-rtk/pages/posts/gip/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ interface HeadingProps {

type Props = HeadingProps & { errorCode?: number }

const postTitleSelector = createSelector(isActivePostLoading, activePostSelector, (isLoading, activePost): string =>
isLoading ? 'Post is loading ...' : `${activePost?.title || 'Empty title'}`,
)
const postTitleSelector = createSelector(isActivePostLoading, activePostSelector, (isLoading, activePost): string => {
if (isLoading) {
return 'Post is loading ...'
}

return `${activePost?.title || 'Empty title'}`
})

const Heading: FC<HeadingProps> = ({ title }) => {
const postTitle = useSelector(postTitleSelector)
Expand Down
9 changes: 7 additions & 2 deletions examples/example-next/eggs/aviasales/events.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import mitt from 'mitt'

export const AviasalesEventEmitter = mitt()

export enum AviasalesEvent {
GET_TICKETS = 'aviasales/GET_TICKETS',
CHANGE_STOPS = 'aviasales/CHANGE_STOPS',
Expand All @@ -12,6 +10,13 @@ export enum ChangeStopsMassive {
UNCHECK_ALL = 'UNCHECK_ALL',
}

type MittEvents = {
[AviasalesEvent.GET_TICKETS]: string | undefined
[AviasalesEvent.CHANGE_STOPS]: number | ChangeStopsMassive
}

export const AviasalesEventEmitter = mitt<MittEvents>()

export const AviasalesPublicAction = {
getTickets() {
AviasalesEventEmitter.emit(AviasalesEvent.GET_TICKETS, AviasalesEvent.GET_TICKETS)
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next/eggs/aviasales/saga/tickets-saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getTickets } from '@/eggs/aviasales/saga/get-tickets'
import { isAllTicketLoadedSelector } from '@/eggs/aviasales/selectors'
import { StoreActionType } from '@/store/action-types'

type ChannelPayload = string
type ChannelPayload = string | undefined

const subscribe: Subscribe<ChannelPayload> = emitter => {
const handler: Handler<ChannelPayload> = payload => {
Expand Down
2 changes: 2 additions & 0 deletions examples/example-next/eggs/count/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Egg } from '@redux-eggs/core'

import { skipHydration } from '@/eggs/count/middlewares'
import { COUNT_REDUCER_KEY, countReducer } from '@/eggs/count/reducer'
import { countWatcher } from '@/eggs/count/saga'
import type { AppStore } from '@/store'
Expand All @@ -10,6 +11,7 @@ export const getCountEgg = (): Egg<AppStore> => {
reducersMap: {
[COUNT_REDUCER_KEY]: countReducer,
},
middlewares: [skipHydration],
sagas: [countWatcher],
}
}
13 changes: 13 additions & 0 deletions examples/example-next/eggs/count/middlewares.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Middleware } from 'redux'

import { COUNT_REDUCER_KEY } from '@/eggs/count/reducer'
import { countSelector } from '@/eggs/count/selectors'
import { StoreActionType } from '@/store/action-types'

export const skipHydration: Middleware = store => next => action => {
if (action.type === StoreActionType.HYDRATE && countSelector(store.getState())) {
delete action.payload[COUNT_REDUCER_KEY]
}

next(action)
}
7 changes: 0 additions & 7 deletions examples/example-next/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
* @type {import('next').NextConfig}
*/
const nextConfig = {
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
// ignoreBuildErrors: true,
},
images: {
domains: ['pics.avs.io'],
},
Expand Down
Loading

3 comments on commit 9d409f8

@vercel
Copy link

@vercel vercel bot commented on 9d409f8 Feb 20, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

redux-eggs-example-next-gip – ./examples/example-next-gip

redux-eggs-example-next-gip-git-main-fostyfost.vercel.app
redux-eggs-example-next-gip-fostyfost.vercel.app
redux-eggs-example-next-gip.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 9d409f8 Feb 20, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

redux-eggs-example-next – ./examples/example-next

redux-eggs-example-next-fostyfost.vercel.app
redux-eggs-example-next-git-main-fostyfost.vercel.app
redux-eggs-example-next.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 9d409f8 Feb 20, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

redux-eggs-example-next-rtk – ./examples/example-next-rtk

redux-eggs-example-next-rtk.vercel.app
redux-eggs-example-next-rtk-fostyfost.vercel.app
redux-eggs-example-next-rtk-git-main-fostyfost.vercel.app

Please sign in to comment.