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

Usage with swoole - ExpressivePage should be stateless #6

Open
nuxwin opened this Issue Feb 26, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@nuxwin
Copy link

nuxwin commented Feb 26, 2019

@froschdesign

Good morning,

I'm switching to swoole. When using swoole, services must be stateless.

This isn't the case of your ExpressivePage implementation which is bound to the navigation service. While I can understand that the navigation service must be created only once, including page containers, the pages for which state is derivated from the current request shouldn't keep their state throughout subsequent requests. Basically put, state of pages should be recalculated on each requests.

Keeping the state of the pages with swoole produce wrong behavior (pages with unexpected active state). One way to workaround the issue is to reset the active state when the RouteResult object is set, that is:

    /**
     * @param RouteResult $routeResult
     */
    public function setRouteResult(RouteResult $routeResult) : void
    {
        $this->active = false; // Make sure that active state will be based on current request
        $this->routeResult = $routeResult;
    }

instead of

    /**
     * @param RouteResult $routeResult
     */
    public function setRouteResult(RouteResult $routeResult) : void
    {
        $this->routeResult = $routeResult;
    }

I'm pretty sure that there are other issues like this with current implementation (such as the hrefCache property) but solving this one would be a good starting point.

Thank you.

@nuxwin nuxwin changed the title Usage with swoole Usage with swoole - ExpressivePage should be stateless Feb 26, 2019

@nuxwin

This comment has been minimized.

Copy link
Author

nuxwin commented Feb 27, 2019

@froschdesign My solution above is bad in regard of usage in async context... We should think about a contextual state...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.