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

Commit

Permalink
Cache panel contents after first load
Browse files Browse the repository at this point in the history
Previously:

1) Panels are by default conditionally rendered,
so each time a panel is closed and reopened,
its contents are recreated.

2) Else, panels can be preloaded if explicitly wanted.
However, this adds extra rendering time.

Now:

Case 2 remains the same.
Authors can still choose to preload their panels if they wish.

For Case 1, we cache the rendered content so as to prevent re-rendering,
which
  a) prevents multiple HTTP requests if using the src attribute
  b) solves issues that stem from the destruction and recreation of
     components:
     MarkBind/markbind#868
     MarkBind/markbind#483

Implementation:

Store an additional `isCached` property, which is set to true
whenever the content is fetched.

When `isCached` is true, we switch from
v-if (conditional rendering)
to
v-show (conditional display)
More info: https://vuejs.org/v2/guide/conditional.html#v-show

As a side effect, since once the panel is loaded v-show is always used,
the v-else part of the template is not needed anymore.

Future work:

Investigate the use of keep-alive:
https://vuejs.org/v2/guide/components-dynamic-async.html

Tried to surround the content with <keep-alive></keep-alive>
but did not seem to be cached.
  • Loading branch information
openorclose committed May 22, 2019
1 parent 386e3f0 commit 38ccc5f
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 252 deletions.
Loading

0 comments on commit 38ccc5f

Please sign in to comment.