Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image loading queuing #11

Merged
merged 4 commits into from
Aug 7, 2019
Merged

Image loading queuing #11

merged 4 commits into from
Aug 7, 2019

Conversation

SkalskiP
Copy link
Owner

@SkalskiP SkalskiP commented Aug 7, 2019

No description provided.

@SkalskiP SkalskiP requested a review from rootkowsky August 7, 2019 19:13
@SkalskiP SkalskiP added the bug Something isn't working label Aug 7, 2019
@@ -0,0 +1,24 @@
export class ImageLoader {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

może ImageLoadManager? ImageLoadQueueManager?
fajnie by było zrobić klasę bazową która pomagałaby implementować kolejkowanie. ale nie rób teraz.
zrobisz jak będziesz miał odpicowaną tą klasę

@@ -0,0 +1,24 @@
export class ImageLoader {

private static queue = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otypuj że zbierasz tutaj funkcje. koniecznie asynchroniczne

private static queue = [];
private static isRunning: boolean = false;

public static add(fx: any) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

też otypuj. wiem że się przypierdzielam ale tak będzie wygodniej później

private static async runTasks() {
while (ImageLoader.queue.length > 0) {
const fx = ImageLoader.queue.shift();
await fx();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ten await działa (tak jak tego oczekujesz) w pętli while? nie wiem xD pytam?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tak, testowałem i śmiga. Dałem wfile, bo jest lepszy od fora, bo mogę w między czasie ushować i shiftować z array i nie musze się martwić tym że form a z góry stałą ilość elementów.

this.resizeCanvas(size);
this.primaryRenderingEngine = new PrimaryEditorRenderEngine(this.canvas, this.imageRectOnCanvas);
this.mountSupportRenderingEngine(activeLabelType);
this.fullCanvasRender()
this.fullCanvasRender();
setTimeout(() => ImageLoader.run(), 10);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no właśnie... dlatego napisałem że to bieda kolejkowanie bo tak zasugerowałem żeby zrobić :/
na tę chwilę to rozwiązanie może być. ale wypadałoby wymyślić jakieś lepsze

@@ -76,14 +82,17 @@ class Editor extends React.Component<IProps, IState> {

public componentDidUpdate(prevProps: Readonly<IProps>, prevState: Readonly<IState>, snapshot?: any): void {
if (prevProps.imageData.id !== this.props.imageData.id) {
this.loadImage(this.props.imageData);
ImageLoader.add(async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ten kawałek kodu się powtarza więc zapisz do metody w tej klasie/utilu

ImageLoader.add(async () => {
await this.loadImage(this.props.imageData, this.props.isScrolling);
});
setTimeout(() => ImageLoader.run(), 10);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tutaj tez są powtarzające się kawałki kodu

@SkalskiP SkalskiP merged commit ae76e5c into master Aug 7, 2019
@SkalskiP SkalskiP deleted the image_loading branch August 7, 2019 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants