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.

Hello

I am playing around with carte blance to attempt to create a prototype of it using angular2. the initial setup was pretty nice, and getting the carteblanche running the frontend in a working environment with webpack.

Now I have a couple of questions regarding the webpack hooks and the frontend. Mainly 2 things :

1 ) I am using the carte-blanche-plugin-before-processing hook to analyze my component. In angular2 components define inputs (equivalent to props in react). I am using http://typedoc.io/ to analyze the component and it gives me a nice representation of the inputs and its types (because most angular2 apps use typescript I am focusing on that now, simplifies a lot). Now the thing is this function is asyncronous and I get this value in a callback. Something like

compilation.plugin('carte-blanche-plugin-before-processing', (data) => {
    // Read the data from this component
    type_doc_parser(data.source, (parsedComponent) => {
        data.AngularSouce = parsedComponent;
    });
});

However this does not work, it is as if this hook is expecting whatever to get applied to the data object to be syncronous. If I do a simple assignment it works fine, but if I assign inside the callback or in any async way it does not work. Maybe something obvious…but I cant seem to figure out why. this can be seen here https://github.com/joaogarin/carte-blanche-angular2/blob/master/plugin.js#L89

2 ) The frontend essencially runs fine, but I am not sure how to actually render stuff in there if that makes sense. In the examples I see from the plugins you provide you use react which renders HTML directly in javscript. That’s not how it works with angular. So in Angular the natural way to do this is to render a component which can then use something called the dynamic component loader to render other components dynamically. but for that I first need to be able to render something inside my frontend. Even if I try to just render static HTML in there, it does not work and prints it as a string only. https://github.com/joaogarin/carte-blanche-angular2/blob/master/frontend/index.ts Right now I am not really doing anything in there…but I would like to just figure out how to get my HTML to render in there properly. Maybe I need to understand better what the return in this function means, where does it go to.

I think cartblance would play very well with angular. There are some tricky things and I dont think getting the metadata from the components is that part, that is actually fairly easy at least with apps running typescript (which are the vast majority). But rendering might be the tricky part.

Angular needs to do a bootstrap to render stuff in the frontend. This means basically that I need to run a “Angular” app in the frontend. This means having a main HTML tag like <app-carte-blanche></app-carte-blanche> and a piece of javascript that will take this and bootstrap the angular app inside it.

This angular app will then load a main component (much like your playground) which will be responsible for rendering the component dynamically depending on the inputs chosen by the user, or the randomize algorythm…I would get into that later as soon as I can render a simple component in the frontend. If I get a component rendering in the frontend everything after that will just fall into place.

If this does not make perfect sense I would say lets get the first issue going, that the second one I still can investigate more. I havent spend all that much time on it, also javascript is kind of my hobbie so I do have some limited experience with it. but seems like this can be a fun thing at least to kickstart and someone can pick up and improve it with me.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
joaogarincommented, Jul 14, 2016

React.createElement seems to be what I was looking for;P

1reaction
mxstbrcommented, Jul 17, 2016

Awesome!! 👍 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plugins - The Angular Book
Plugins are used to allow third-party developers extend your application by utilizing the redistributable extensions that provide new features for the ...
Read more >
EXPLORE ANGULAR RESOURCES
Angular Community Meetup. Come learn technical skills and network at this monthly, multi-series, multi-event, multi-timezone online meetup.
Read more >
Plugin Architecture for Angular Libraries using Dependency ...
The plugin architecture is a well-known software design pattern used for its flexibility, extensibility, and isolation.
Read more >
Implementing a Plugin Architecture with Angular and ...
In Angular a plugin architecture is ensured by following two simple steps: have parent component allow rendering of inner components by using ng-content...
Read more >
How to build a plugin/extensible application architecture in ...
Inside the “angular-plugin-architecture” folder let's create a folder named “plugins” and inside that one create a folder named “plugin-a”.
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