rawmodel/framework

The objects within contextable are "shareable" between both front and backends?

smolinari opened this issue · 4 comments

Hi,

I am really starting to like the concepts used in contextable.

One thing I'd really like to make sure of. From my readings (thanks for the great docs) and if I understand everything correctly, validation that is defined on the server side can be/ is also used for the client side? In other words, certain validation rules only need to be defined once. Is this correct? If yes, can this kind of back.end/front-end sharing concept be extended to other business logic?

Scott

Yes. As long as your schema instanceMethods, classMethods and types have code that works on the server and in the browser, then you can use the same code for the server and the browser. Example... if your Schema is using e.g. mongodb package, then it won't work in browsers. Just make sure that everything your write works everywhere.

Right. That is logical that anything "mongo" won't work on the client.

So, I come back to composibility. I haven't dug at all into using contextable, so I apologize if my question sounds naive, but I still think the context object should be composable and, for instance, be composable between front-end and back-end environments. That way, a front-end context can have many of the objects and methods that the back-end also uses, but only those that can be used on the front-end. In other words, standard validation and business logic "rules" would need some sort of flag to indicate the environment they can be used in. The context object would then be built accordingly. From your answer, I would imagine that this kind of composable context per environment isn't yet possible?

Scott

This package is unopinionated which means you are in charge for the structure and logic.

That is a good thing. I guess I'll have to make is opinionated. LOL!

Thanks again for your tips!

Scott