Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upDocs: Add recipe guide for using Store with custom elements #1621
Comments
|
Hey @brandonroberts , |
|
@santoshyadav198613 In theory, it shouldn't be much different than implementing NgRx in a regular scenario. Custom elements can have services (injectables) injected into the constructor just like regular components. My recommendation would be to create a GitHub repository that:
Once we prove this works we can back into an article/guide that shows how to do this. Here's the Angular docs page for custom elements: https://angular.io/guide/elements#using-custom-elements What do you think @brandonroberts? |
|
Thanks @wesleygrimes , Will start working on the app. Regards, |
|
@santoshyadav198613 any luck on the app? I was thinking about taking a crack at this, but don't want to steal your thunder. |
|
Hey @wesleygrimes, Regards, |
|
@santoshyadav198613 Sounds good my friend! |
|
Hi @wesleygrimes , Repo : https://github.com/santoshyadav198613/ngRxElementDemo |
|
@santoshyadav198613 this is looking good! Can you take it a step further and make each piece a separate custom element? Right now it's all together in one counter element, but I think the end goal is to show multiple counter elements communicating with each other through the Store. |
thanks sure will start working on it. |
|
Hi @wesleygrimes , |
@santoshyadav198613 This is looking good! @timdeschryver @brandonroberts What do you think? Should the example go any further like showing the elements being used in a non-angular, vanilla js scenario? Or is this good enough? |
|
Hi @timdeschryver @brandonroberts , Any update to move forward with this task. |
|
I think it's a good start. Probably would be better to build the components in a separate lib and use them in the example. |
|
Sounds good, will make the changes. |
|
Hi @brandonroberts , Added a library project, the only problem is it is not working on stackblitz. |
|
Yeah I would expect issues on Stackblitz. This kind of edge case doesn’t always work there. I will pull locally and test out.
…-Wes
On Apr 8, 2019, at 2:02 PM, Santosh Yadav ***@***.***> wrote:
Hi @brandonroberts ,
Added a library project, the only problem is it is not working on stackblitz.
But verified locally works fine.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
@santoshyadav198613 looks good to me! |
thanks @brandonroberts So where we want the documentation to be added. |
|
I wasn't up to date with Angular elements, but this is neat! |
|
Thanks @timdeschryver , Sure will start writing in weekend, would be happy if you can review it before i publish. |
|
Definitely agree. A post on this would be good |
|
@santoshyadav198613 Feel free to send any draft of the post my way (and I'm sure the other guys too) and we will be happy to review, edit, etc... before you publish. |
|
Hi @wesleygrimes @timdeschryver @brandonroberts , Please suggest the changes |
|
@santoshyadav198613 we will review. Certainly has potential to be a great read! |
|
We should also think about getting this or similar content into a recipes page in the docs for NgRx now that you have proved it works. |
|
@brandonroberts @wesleygrimes Can we have one example of custom element's exposed method where we call a ngrx action. I was trying to work with custom elements + NgRX and tried to integrate the custom element in an angularjs app. Amazed to see everything working seamlessly!!! But I am stuck at one place. Whenever from my angularjs app I am calling the custom element exposed method change detection is not happening. Calling code in angular js Exposed method in Angular 7 + @ngrx/store(7.3.0) + Custom Elements:
I tried calling the _refreshSettingProgressValue _ inside Angular7 app on click of a dummy button and everything works but when I call it outside Angular context I am not able to see the changes in UI. I have already tried ngzone-element-strartergy but it didnt resolve my issue
I believe we can call changeDetection explicitly but with ngrx how and where can we do that? Thanks |
|
Happy to hear this also works for AngularJS I think currently the only options would be to listen to actions inside the component itself or a better way would to trigger the CD when the select emits a new value.
|
|
Hi Guys, |
|
@timdeschryver
Tried firing change detection on every emit value after
but it doesn't work!!!. I am not sure why. Can anyone please have an explanation. |
|
HI @wesleygrimes @timdeschryver , |
|
Thanks for review @brandonroberts , i have made the changes. |
|
I didn't make it all the way through. I will leave more feedback later today |
|
@santoshyadav198613 Now that you have the blog posted, would you be willing to work on submitting a PR that morphs the blog post into a guide for the docs? I suspect there will be a lot of back and forth, but it would be helpful to get this started. If you need help on submitting PR's for docs, let us know. |
|
Sure @wesleygrimes PR coming soon. |
|
One thing guys, if we add this example, we have already seen Angular Libraries are not supported on StackBlitz. We can give only download option. |
|
Hi @brandonroberts , @wesleygrimes where to add the guide, should I add it in Recipes section under Getting Started of Store. |
|
Hi Santosh,
How about under Store > Recipes > Custom Elements?
Thanks,
Wes
… On May 4, 2019, at 2:21 PM, Santosh Yadav ***@***.***> wrote:
Hi @brandonroberts , @wesleygrimes where to add the guide, should I add it in Getting Started section of Store a new section for Store With Angular Elelments
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
I read the title thinking of a different scenario, maybe it's easier to implement? Edit: is this worthy of a new issue or a separate story? |
|
Nice article! @santoshyadav198613 |
|
Closing this for now |
@METACEO Any update on this? Need my element instances have separate store instances so that they don't interfere. |
|
@Ashwin2488 nah, I haven't experimented with anything like this in awhile. If I had to jump back into this today, I'd probably start with this @ngrx/component-store - how does this look to you? |
|
FYI @Ashwin2488, sure enough, ngrx/component-store seems to be a good lead! Local state management with @ngrx/component-store by Alex Okrushko || Angular Conference |
People have asked how you use a single Store across multiple custom elements.
Requirements:
projects/ngrx.io/examplesthat is referenced in the guide.