Code Monkey home page Code Monkey logo

Comments (6)

zaceno avatar zaceno commented on April 27, 2024

After some reflecting: perhaps the right place to put this sort of functionality would be in the routing. But that would necessarily make the router more complex, which may be antithetical to the principles of hyperapp.

Either way, I'm still curious how (any of) you would solve the basic problem of authenticated access to specific routes.

from hyperapp.

tzellman avatar tzellman commented on April 27, 2024

Do you have an example you could share?

from hyperapp.

zaceno avatar zaceno commented on April 27, 2024

sure thing. Does this code-pen clarify things? http://codepen.io/anon/pen/jyQWpv

from hyperapp.

zaceno avatar zaceno commented on April 27, 2024

Actually, I think I'm going to close this one.

I was hell-bent on keeping the login page in it's own /login route (rather than as a conditionally rendered view), but the more I think about it, the less important that login-route seems. So I withdraw the question.

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

@zaceno Please share your findings back with us when, and if you do finish the project you're talking about. 🙏

from hyperapp.

zaceno avatar zaceno commented on April 27, 2024

Will do!

I am actually porting (incrementally) an app I've already written with vue.js to hyperapp (just for fun :) ). In vue, I was using the approach of having a special route for the login page, and a guard for the authenticated pages (as I was trying to do in my examples above).

The more I thought about it, I realized that the solution I have in Vue, hinges on the fact that the Vue-router supports a kind of nested component routing (where for example a route '/A/B' means "render parent view A, with the child view B, and route '/A/C' means "render parent view A with child view C")

Since the hyperapp router is intentionally much more simplistic, I undertand I should avoid too much routing-voodoo as I port over. For different tools, solve the same problem in different ways, each appropriate to the respective tool :)

For now, I'll go with conditional rendering. But if I happen to have any neat ideas, I'll be sure to submit a PR.

from hyperapp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.