question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Any plan for docs of abstract components?

See original GitHub issue

There are several built-in abstract components, such as transition, keep-alive. However, the official guide doesn’t tell the developers that they could also create their own.

Here’s a possible use case. If the user’s network is very good, I may want to guess his/her behavior based on some rules, and prefetch some async data or routes. So I create a prefetch abstract component. When the user really does what I have guessed, the UI could response immediately.

After read source code of the built-in abstract components, I found that there are pitfalls I didn’t realize. For example, an abstract component may contain another abstract component. Then I start to worry whether I could use it the right way.

Is abstract designed to be internal only, or is there any plan for the docs?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
vbarbaroshcommented, Jan 21, 2017

Hi, I asked a question on stackoverflow related to this issue. My use case is simple. I just want to have a component which will add a property to its child component but will not change html at all.

From this:

<div id="app" class="container">
    <foo>
        <p>hello</p>
    </foo>
</div>

To this:

<div id="app" class="container">
     <p>hello</p>
</div>
2reactions
giodifcommented, Jun 23, 2018

Hi. I have run into a case where this might be pretty useful. I’m new to Vue, so there may already be a good solution for what I’m presenting. I looked through the docs and through issues and didn’t see anything that might help.

I’m working on a project that uses canvas pretty extensively to draw graphs. I’ve worked with React where creating abstract components isn’t a problem. I guess that I assumed the case would be the same in Vue (not a criticism, Vue is the cat’s pajamas).

Let me explain the use case:

I’d like to make a series of components that encapsulate drawing operations to a canvas. Think: <weighted-edge>, <unidirectional-edge>, <bidirectional-edge>, <graph-node>, etc. These nodes need simply to contain the logic for drawing to the canvas, hence no rendering new DOM elements. I originally sketched out a hierarchy like so, (before I painted myself into a corner):

<canvas-stage>
    <weighted-edge v-for="edge in edges" ctx="ctx">
    <graph-node v-for="node in nodes" ctx="ctx">
    ...etc...
</canvas-stage>

The idea is that a parent component handles the canvas and passes the context down into all the child abstract components, which handle drawing. My thinking is that this might provide a simple way of managing draw layers to the canvas and for maintaining drawing operation code. If you’ve ever worked on a project with lots of drawing, it usually ends up a pain to maintain.

My point is that some ‘view’ elements aren’t always DOM elements. The canvas is a pretty complex element and it’d be most excellent to use Vue components (and vuex) to manage the state of a canvas image. Having access to abstract components would make it somewhat easier to incorporate more robust drawing libraries as well.

Anywho, just my two cents.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Writing Abstract Components with Vue.js - DigitalOcean
Abstract components are like normal components, except they don't render anything to the DOM. They just add extra behavior to existing ones. You ......
Read more >
Organizing Your Social Sciences Research Paper
Sometimes your professor will ask you to include an abstract, or general summary of your work, with your research paper. The abstract allows...
Read more >
Writing an Abstract Introduction to Lesson [5 minutes]
This individual lesson plan focuses on writing an abstract. The first several weeks of the course are spent breaking apart the components of...
Read more >
How To Write an Abstract in 7 Steps (With an Example) - Indeed
Abstracts generally contain four main elements: Purpose: Clearly define the purpose and importance of your research. This includes a statement ...
Read more >
Abstract Component References - W3C
Given that these components are information about a different resource, the different resources are called abstract components. A description of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found