-
Notifications
You must be signed in to change notification settings - Fork 374
Conversation
|
This is great. We can hide lg logic from store actions! Then we can extend those lg handlers and add apis like 'copyTemplate' |
Yes, I'm trying new lg parser, and collecting feedback to lg team. if we want add some api or reporting issue, we can note here. |
| } | ||
|
|
||
| export function updateTemplate(content: string, templateName: string, { Name, Parameters, Body }: Template): string { | ||
| const resource = LGParser.parse(content); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the store should hold a bunch of resources? so we don't have to parse it every time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgUtil do not have state, or we pass a parsed content to it ?
content: string ---> content: LGResource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought again, this way would increase the cost of caller.
how about cache it at lgUtil, then calculate hash diff determine re-parse it or not.
const localParsedLG = { id, contentHash, LGResource };
export function updateTemplate(content: string, templateName: string, { Name, Parameters, Body }: Template): string {
const contentHash = hash(content);
let resource;
if( contentHash in localParsedLG ) {
resource = localParsedLG.get(contentHash)
} else {
resource = LGParser.parse(content);
//update localParsedLG
}
...
}
maybe this method should implmented withing lg parser
|
Feature request: can we have a const copyTemplate: (content: string, fromTemplateName: string, toTemplateName: string) => string;It's like a synthesized api consists of |
Sure~, will add it. one more thing to confirm.
if |
|
This PR origin lost fork information, can't auto update commit anymore, move to #1512 |
Description
use lg parser api do template add/update/delete, instead of manually stitching text file.
Task Item
fix #1211
Type of change
Please delete options that are not relevant.
Checklist
Screenshots
Please include screenshots or gifs if your PR include UX changes.