kendraio / kendraio-app

Kendraio App
https://app.kendra.io
MIT License
22 stars 6 forks source link

Create a shared state service #237

Closed the-greenman closed 2 years ago

the-greenman commented 2 years ago

I'm exploring how to create a mirror of context in a shared service. This is my first experiment in splitting the flow from the interface.

If this work is successful, it will be possible for a visual component to subscribe to changes in the shared context, and update it's display.

I have many questions about how this can be achieved. I will be logging my experiments here.

the-greenman commented 2 years ago

Part 1: How do I create a service?

https://angular.io/tutorial/toh-pt4

the-greenman commented 2 years ago

Hmm. We already have a context service.

the-greenman commented 2 years ago

The existing context data service manages authentication data for http and the query blocks. I'm investigating whether or not I should build on top of this tool.

the-greenman commented 2 years ago

I will not build on this.

Digging into this code, I am finding myself dealing with what feels like a completely different architecture, an older geological layer. Tools that I have never seen, and have no idea how to access.

While looking around here, I feel that we would possibly benefit from leaving a lot of this behind in a branch, and seeing what code we still want to keep in place.

the-greenman commented 2 years ago

current challenges: I've created a new bloc type. But, cannot actually get it to render. I feel that I'm missing a step in the setup.

To keep moving forward, I've started to use the template block as my experiment. I have now actually successfully updated the template content using the shared context. But.. Angular is complaining. I'm trying to work out why.

The app is also crashing on me fairly often. I don't think that this is to do with my work. There are a number of errors in the background that I'm watching.

the-greenman commented 2 years ago

global-error-handler.service.ts:25 Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value for 'innerHTML': 'hello '. Current value: 'hello two'.. Find more at https://angular.io/errors/NG0100

I've got a working template block that it capable of dynamically updating it's content. However, I'm breaking some rules and need to work out if there is a correct way to do this.

https://hackernoon.com/everything-you-need-to-know-about-the-expressionchangedafterithasbeencheckederror-error-e3fd9ce7dbb4

The process now works if I wrap my update to the html in "{ setTimeout(() =>{this.render()})}

the-greenman commented 2 years ago

I've got a working shared context. However, I've now found the next level of challenge. Using this capability encourages setting up many blocks that feed data into the shared context, but don't modify the data itself. This causes the change detection to kick in, and results in the flow not being fully executed.

the-greenman commented 2 years ago

Bug found.

Context-save works differently from within a batch. When running in a normal, non-batch, flow, context-save will always skipFirst. We generally don't want the null data written to context. However the batch will never run in that first cycle, so, within a batch, we do want to save on first run - because the batch would only have data to execute after the first run.

the-greenman commented 2 years ago

I've going to put my testing plans aside for now. I don't quite know how to effectively fake the location services in the way that I need. I'll come back to this.

lukestanley commented 2 years ago

What about an end to end test at least?

On Fri, 10 Dec 2021 at 12:54, Greenman @.***> wrote:

I've going to put my testing plans aside for now. I don't quite know how to effectively fake the location services in the way that I need. I'll come back to this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kendraio/kendraio-app/issues/237#issuecomment-990949827, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACK33643X7XQOPYYJ44753UQH2AHANCNFSM5H5IRIGA .

the-greenman commented 2 years ago

Working on the e-2-e now