Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Breeze.js typed entities

Is there a way to create typed entities using Breeze in the same way that JaySvcUtil works for JayData? Does this include Typescript support - also is there general Typescript support within the Breeze framework?

like image 483
user1894205 Avatar asked Dec 11 '12 09:12

user1894205


1 Answers

This gist contains a modified version of T4TS that contains some initial support for generating "design time Javascript classes for each entity" with support for Breeze.

https://gist.github.com/alexdresko/5393155

So far, it suits my needs. I'm pretty sure you need to have the DefinitelyTyped Breeze definition in your solution for this to work properly.

Maybe this is something that could be added to T4TS permanently? Maybe it's something for the Breeze team to consider? Or maybe it's just stupid and doesn't really work for anyone but me. :)

In my dataservice, I can do something like:

    createOrganization() : T4TS.Organization {
        return <T4TS.Organization>this.manager.createEntity("Organization");
    }

Then, in my VM, all of this code is nicely typesafe..

    organizationSubmit() {
        this.editingOrganization(false);
        var newOrganization = this.dataservice.createOrganization();

        newOrganization.Name(this.organizationNameInput());
        if (newOrganization.entityAspect.validateEntity()) {
            this.extendOrganization(newOrganization);
            this.organizations.push(newOrganization);
            this.dataservice.saveChanges();
            this.organizationNameInput("");
        } else {
            this.handleItemErrors(newOrganization);

        }
    };

I don't really know where to go with this from here. I tried forking T4TS, but didn't have time to figure out his build system. Hence the gist. Opinions are certainly welcome.

like image 159
Alex Dresko Avatar answered Oct 30 '22 23:10

Alex Dresko