Skip to content

Commit

Permalink
Move data loading from firstUpdated to connectedCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
blikblum committed Dec 9, 2019
1 parent 71982fb commit 4aab874
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/pages/Article/article-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class ArticlePage extends Component {
match: {}
}

firstUpdated() {
connectedCallback() {
super.connectedCallback()
const slug = this.match.params.id
this.context.stores.articlesStore.loadArticle(slug, { acceptCached: true })
this.context.stores.commentsStore.setArticleSlug(slug)
Expand Down
3 changes: 0 additions & 3 deletions src/pages/Home/home-main-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ class MainView extends Component {
connectedCallback() {
super.connectedCallback()
this.context.stores.articlesStore.setPredicate(this.getPredicate())
}

firstUpdated() {
this.context.stores.articlesStore.loadArticles()
}

Expand Down
3 changes: 2 additions & 1 deletion src/pages/Home/home-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import './home-main-view'
class HomePage extends Component {
static observedContexts = ['stores']

firstUpdated() {
connectedCallback() {
super.connectedCallback()
this.context.stores.commonStore.loadTags()
}

Expand Down
3 changes: 0 additions & 3 deletions src/pages/editor-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ class EditorPage extends Component {
connectedCallback() {
super.connectedCallback()
this.context.stores.editorStore.setArticleSlug(this.match.params.slug)
}

firstUpdated() {
this.context.stores.editorStore.loadInitialData()
}

Expand Down
8 changes: 2 additions & 6 deletions src/realworld-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@ class App extends Component {

connectedCallback() {
super.connectedCallback()
if (!this.stores.commonStore.token) {
this.stores.commonStore.setAppLoaded()
}
}

firstUpdated() {
if (this.stores.commonStore.token) {
this.stores.userStore
.pullUser()
.finally(() => this.stores.commonStore.setAppLoaded())
} else {
this.stores.commonStore.setAppLoaded()
}
}

Expand Down

0 comments on commit 4aab874

Please sign in to comment.