reapp / reapp-routes

Simple route DSL
MIT License
34 stars 13 forks source link

The code is a little hard to understand. #2

Closed williamwa closed 9 years ago

williamwa commented 9 years ago
module.exports = ({ routes, route }) =>
  routes(require,
    route('app', '/', { dir: '' },
      route('home', '/',
        route('sub')
      )
    )
  );

the /home and /home/sub path not exist. it need use / and /sub. and why we can assign 2 level of route with path /, that is confusing.

natew commented 9 years ago

It's because we're putting the '/' on the home route, actually mounting home on the root, so sub becomes the one after that.

But, you may be right for the out-of-the-box configuration, we want it to be as simple to understand as possible. I have some bigger ideas on this actually, but for now we can wire it to remove the '/' and that would be more understandable.

williamwa commented 9 years ago

What is the big ideas? I am very interested on reapp project, so maybe I can help on this one.

natew commented 9 years ago

One is basically thoughts on making it easier to get into development in general. I want reapp to be orders of magnitude easier to make apps than before.

You can do stuff like visual editors, but another route would be to hack into Webpack and try and automate as much stuff as possible.

One of those thoughts was with routes, to just get rid of them completely. Since we are already mapping routes to directory structure, why not the reverse. If we had a pages folder, that could be automatically read in and translated to routes. We'd need to change the syntax for parameters, maybe attaching them to the component itself which is more limiting, but given we'd be making apps routes aren't very important to begin with (that's a dangerous logical path to go down though).

On those same lines I'm thinking of encouraging loading all of reapp-ui as well as React automatically for all components. Another dangerous idea, but if we could do it right would save a lot of time and hassle.

Final one: just export a plain JS object for each component:

export {
  render() {
    <View title="Hello">
    </View>
  }
}

If we auto-import React/reapp we can write components with that little code, maybe even less! I need to think about this all more, I think again it would need to be done the right way, but I'm starting to think about optimizations that would make writing with reapp much much faster, so these are some of the thoughts.

natew commented 9 years ago

If you want to help today, the best areas are all the bugs especially visual ones in Safari, followed by adding in some components we're missing, as well as working on the Material UI theme. The routes stuff is big talk, for now I'd just simplify the default app routes so they are easier to understand.

natew commented 9 years ago

This is also now simplified more with reapp-kit, going to close this for now. Let me know if you still have questions.