0.4.5 • Published 4 months ago
mobx-strapi v0.4.5
MobX-Strapi
MobX SDK for Strapi headless CMS
Version
SemVer | branch | status | ES decorator | MobX | Strapi |
---|---|---|---|---|---|
>=0.5 | main | ✅developing | stage-3 | >=6.11 | v4 |
>=0.3 <0.5 | main | ❌deprecated | stage-2 | >=4 <6.11 | v4 |
<0.3 | master | ❌deprecated | stage-2 | >=4 <6 | v3 |
Usage
npm i mobx-restful mobx-strapi koajax
model/service.ts
import { HTTPClient } from 'koajax';
export const strapiClient = new HTTPClient({
baseURI: 'http://your.production.domain/path/optional',
responseType: 'json'
});
model/Article.ts
import { StrapiListModel } from 'mobx-strapi';
import { strapiClient } from './service';
export type Article = Record<'id' | 'title' | 'summary', string>;
export class ArticleModel extends StrapiListModel<Article> {
client = strapiClient;
baseURI = 'articles';
}
export default new ArticleModel();
page/Article/index.tsx
Use WebCell as an Example
import { WebCell, component, observer, createCell } from 'web-cell';
import articleStore from '../../model/Article';
@component({
tagName: 'article-page'
})
@observer
export class ArticlePage extends WebCell() {
connectedCallback() {
articleStore.getList();
}
disconnectedCallback() {
articleStore.clear();
}
render() {
const { currentPage } = articleStore;
return (
<ul>
{currentPage.map(({ id, title, summary }) => (
<li>
<a href={`#/article/${id}`}>{title}</a>
<p>{summary}</p>
</li>
))}
</ul>
);
}
}
0.5.0
4 months ago
0.4.5
9 months ago
0.4.3
9 months ago
0.4.2
11 months ago
0.4.1
1 year ago
0.4.0
1 year ago
0.4.0-rc.6
1 year ago
0.4.0-rc.5
1 year ago
0.4.0-rc.4
1 year ago
0.4.0-rc.2
2 years ago
0.4.0-rc.0
2 years ago
0.3.0-alpha.0
2 years ago
0.2.4
3 years ago
0.2.3
3 years ago
0.2.2
3 years ago
0.2.1
3 years ago
0.2.0
3 years ago