Dangular - D Rest server + Angular frontend

Etienne Cimon via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 19 16:49:15 PDT 2015


On Sunday, 19 July 2015 at 19:54:31 UTC, Jarl André Hübenthal 
wrote:
> Hi
>
> I have created a personal project that aims to learn myself 
> more about D/vibe.d and to create a simple and easy to grasp 
> example on Mongo -> Vibe -> Angular.

Nice ! I'm also working on a project like this, using some paid 
angularjs admin template from themeforest, although I'm powering 
it with Vibe.d / Redis and PostgreSQL 9.4 with its new json type.

> controllers, but it works as a bootstrap example. I am thinking 
> to create another view that uses ReactJS because its much much 
> more better than Angular.

ReactJS has been very promising and I hear a lot of hype around 
it. However I believe Angular lived through its hype and is now 
more mature in plenty of areas, for example its Ionic framework 
for cross-mobile apps is reaching its gold age with seemingly 
fluid performance on every device! With vibe.d being a 
cross-platform framework, you'd be even able to build a Web 
Application that communicates with a client-side OS API, 
effectively closing the gap between web dev and software dev.

> So, there is two structs, but I really only want to have one. 
> Should I use classes for this? Inheritance?

Vibe.d is famous for its compile-time evaluation, understanding 
structures like with reflection but producing the most optimized 
machine code possible. You won't be dealing with interfaces in 
this case, you should look at the UDA api instead: 
http://vibed.org/api/vibe.data.serialization/. For example, if 
your field might not always be in the JSON, you can mark it 
@optional.

struct PersonDoc {
	@optional BsonObjectID _id;
	ulong id;
	string firstName;
	string lastName;
}

You can also "compile-time override" the default 
serialization/deserialization instructions for a struct by 
defining the function signatures specified here:
http://vibed.org/api/vibe.data.json/serializeToJson
or the example here:
https://github.com/rejectedsoftware/vibe.d/blob/master/examples/serialization/source/app.d

This being said, your questions are most likely to be answered if 
you ask at http://forum.rejectedsoftware.com


More information about the Digitalmars-d-learn mailing list