Progress on DotNetVideos


I am happy to say that I am actually, really, making some progress on the project these days. Maybe that’s not THE progress I’d like to have but still, things are kind of simply moving forward.

I will discuss some specific topics I am working on lately below, but generally speaking, it seems that progress is a good word to describe it globally.

Entities Validation on Client and Server

Cool thing about JavaScript that people used to mention everywhere is that you can have one codebase working on both server and client side. That was supposed to make your life easier because:

  • you don’t need to learn different languages
  • you may share your classes and feel you keep your code DRY

I do confirm the first part, but only partially, as in JavaScript you still need to master client-side and servers-side packages to be able to code fast – and that is something you may believe me, is changing dramatically fast, and contains a lot of elements, especially if your server-side is typescript and some database like mongodb.

I am, however, not so confident about the second part. Of course I am still a newbie in this whole JavaScript world, but when you want to check things about conception in .NET solution, you basically just need to find the right post on the web – either stackoverflow, or some other portal (like microsoft support pages). It’s usually already there, waiting for you to pick up this solution and move on. The thing is, that it’s not so obvious in JavaScript world. I find myself very often browsing some github issues to find a way to move on. I know that you may say that it’s good because open source means very often github repos, so also issues are listed there, but somehow I can just feel that even if .NET was not open-source, it was still pretty easy to find a solution to nearly all problems I encountered so far.

Validation, for instance, works fine in Angular2, even better than I would think about it initially, thanks to RxJS. But what if on server side I don’t have angular? Well, we need to find another way, so it’s not the same code already, is it? I hope I’ll find some nice way to resolve this kind of topics, because for now it seems to me it’s not really one code, it’s only one language. Believe me that given the number of different packages to handle both cases, it doesn’t help that much, only ‘a little’.

Reactive Extensions for JavaScript and Angular2

I’ve always been a fan of Rx, it just ‘feels right’. Of course the source of my interest was .NET Rx invented by Eric Meijer. Since he’s now not a Microsoft guy, and basically nothing was protected anyway, you have to know: it’s available almost everywhere.

So you learn about the basics, you check the different operators and examples on the web, you feel this is nice and cool but how do you employ it in your daily work? You may feel in the beginning that it’s a hard thing, but … Angular2 does it for you.

Angular 2 uses RxJs in many places, for instance:

  • In core logic implementation (e.g. EventEmitter)
  • In its API, like Forms and the HTTP module

Having Observables in Forms out-of-the-box was very surprising for me at first. Then I saw it again in HTTP and realized it’s really a very good fit. So for instance, if you check my video.service.ts on the client side, you will find something like:

getVideos() {
return this.http.get('/api/video')
.map<IVideo[]>(res => res.json());


And that may not look extraordinary at first, but you have to know, that map operator is not coming from JavaScript, it’s an Rx operator. So when you check the definition, you’ll see:

map: <R>(project: (x: T, ix?: number) => R, thisArg?: any) => Observable<R>;

which means that you’re now living in Rx world, pretty simple, huh? This has impact on how are you dealing with such data, so if you get Observable from the method, you need to subscribe to it:

.subscribe((res) => ...)

On a second thought, it seems normal that Rx fits well here, due to the asynchronous programming model of nodejs. I really love this sort of surprises as I move on with my project.

Not that I don’t have problems anymore 🙂

I know that if somebody reads my blog from the beginning, he probably wouldn’t survive another post about problems. Here it is, another one!

I can’t debug my code with VS Code. I believe it’s because of webpack doing its magic and some magic configurations I need to adapt to make it fully working, but the facts are that:

– I can see the console.log messages, so it attaches properly to the chrome session

– I can’t hit the breakpoint as for some reason VS Code cannot map the JS code with my typescript files as it runs.

Thanks God it is just a nice feature that I didn’t need yet.

I will try to advance with the project regularly now. Stay tuned.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.