Skip to content

Commit

Permalink
chore: upgrade to mobx@6 (#1412)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy authored Oct 13, 2020
1 parent 84ab95d commit a0f15d9
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 13 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"jest": "^26.1.0",
"license-checker": "^25.0.1",
"lodash": "^4.17.19",
"mobx": "^5.15.4",
"mobx": "^6.0.1",
"prettier": "^2.0.5",
"raf": "^3.4.1",
"react": "^16.13.1",
Expand All @@ -129,7 +129,7 @@
},
"peerDependencies": {
"core-js": "^3.1.4",
"mobx": "^4.2.0 || ^5.0.0",
"mobx": "^6.0.1",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"styled-components": "^4.1.1 || ^5.1.1"
Expand Down
2 changes: 2 additions & 0 deletions src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import 'core-js/es/promise';

import 'core-js/es/array/find';
import 'core-js/es/object/assign';
import 'core-js/es/object/entries';
import 'core-js/es/object/is';
import 'core-js/es/string/ends-with';
import 'core-js/es/string/starts-with';

Expand Down
4 changes: 3 additions & 1 deletion src/services/MenuStore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { action, observable } from 'mobx';
import { action, observable, makeObservable } from 'mobx';
import { querySelector } from '../utils/dom';
import { SpecStore } from './models';

Expand Down Expand Up @@ -76,6 +76,8 @@ export class MenuStore {
* @param scroll scroll service instance used by this menu
*/
constructor(spec: SpecStore, public scroll: ScrollService, public history: HistoryService) {
makeObservable(this);

this.items = spec.contentItems;

this.flatItems = flattenByProp(this.items || [], 'items');
Expand Down
4 changes: 3 additions & 1 deletion src/services/models/Callback.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { action, observable } from 'mobx';
import { action, observable, makeObservable } from 'mobx';

import { OpenAPICallback, Referenced } from '../../types';
import { isOperationName, JsonPointer } from '../../utils';
Expand All @@ -19,6 +19,8 @@ export class CallbackModel {
pointer: string,
options: RedocNormalizedOptions,
) {
makeObservable(this);

this.name = name;
const paths = parser.deref<OpenAPICallback>(infoOrRef);
parser.exitRef(infoOrRef);
Expand Down
4 changes: 3 additions & 1 deletion src/services/models/Field.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { action, observable } from 'mobx';
import { action, observable, makeObservable } from 'mobx';

import {
OpenAPIParameter,
Expand Down Expand Up @@ -61,6 +61,8 @@ export class FieldModel {
pointer: string,
options: RedocNormalizedOptions,
) {
makeObservable(this);

const info = parser.deref<OpenAPIParameter>(infoOrRef);
this.kind = infoOrRef.kind || 'field';
this.name = infoOrRef.name || info.name;
Expand Down
4 changes: 3 additions & 1 deletion src/services/models/Group.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { action, observable } from 'mobx';
import { action, observable, makeObservable } from 'mobx';

import { OpenAPIExternalDocumentation, OpenAPITag } from '../../types';
import { safeSlugify } from '../../utils';
Expand Down Expand Up @@ -35,6 +35,8 @@ export class GroupModel implements IMenuItem {
tagOrGroup: OpenAPITag | MarkdownHeading,
parent?: GroupModel,
) {
makeObservable(this);

// markdown headings already have ids calculated as they are needed for heading anchors
this.id = (tagOrGroup as MarkdownHeading).id || type + '/' + safeSlugify(tagOrGroup.name);
this.type = type;
Expand Down
4 changes: 3 additions & 1 deletion src/services/models/MediaContent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { action, computed, observable } from 'mobx';
import { action, computed, observable, makeObservable } from 'mobx';

import { OpenAPIMediaType } from '../../types';
import { MediaTypeModel } from './MediaType';
Expand Down Expand Up @@ -26,6 +26,8 @@ export class MediaContentModel {
public isRequestType: boolean,
options: RedocNormalizedOptions,
) {
makeObservable(this);

if (options.unstable_ignoreMimeParameters) {
info = mergeSimilarMediaTypes(info);
}
Expand Down
4 changes: 3 additions & 1 deletion src/services/models/Operation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { action, observable } from 'mobx';
import { action, observable, makeObservable } from 'mobx';

import { IMenuItem } from '../MenuStore';
import { GroupModel } from './Group.model';
Expand Down Expand Up @@ -84,6 +84,8 @@ export class OperationModel implements IMenuItem {
private options: RedocNormalizedOptions,
isCallback: boolean = false,
) {
makeObservable(this);

this.pointer = operationSpec.pointer;

this.description = operationSpec.description;
Expand Down
4 changes: 3 additions & 1 deletion src/services/models/Response.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { action, observable } from 'mobx';
import { action, observable, makeObservable } from 'mobx';

import { OpenAPIResponse, Referenced } from '../../types';

Expand Down Expand Up @@ -26,6 +26,8 @@ export class ResponseModel {
infoOrRef: Referenced<OpenAPIResponse>,
options: RedocNormalizedOptions,
) {
makeObservable(this);

this.expanded = options.expandResponses === 'all' || options.expandResponses[code];

const info = parser.deref(infoOrRef);
Expand Down
4 changes: 3 additions & 1 deletion src/services/models/Schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { action, observable } from 'mobx';
import { action, observable, makeObservable } from 'mobx';

import { OpenAPIExternalDocumentation, OpenAPISchema, Referenced } from '../../types';

Expand Down Expand Up @@ -72,6 +72,8 @@ export class SchemaModel {
private options: RedocNormalizedOptions,
isChild: boolean = false,
) {
makeObservable(this);

this.pointer = schemaOrRef.$ref || pointer || '';
this.rawSchema = parser.deref(schemaOrRef);
this.schema = parser.mergeAllOf(this.rawSchema, this.pointer, isChild);
Expand Down
5 changes: 5 additions & 0 deletions src/standalone.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import * as React from 'react';
import { hydrate as hydrateComponent, render } from 'react-dom';
import { configure } from "mobx"

import { Redoc, RedocStandalone } from './components/';
import { AppStore, StoreState } from './services/AppStore';
import { debugTime, debugTimeEnd } from './utils/debug';
import { querySelector } from './utils/dom';

configure({
useProxies: 'ifavailable'
})

export { Redoc, AppStore } from '.';

export const version = __REDOC_VERSION__;
Expand Down

0 comments on commit a0f15d9

Please sign in to comment.