InfomediaLtd / angular2-redux-example

Example project for using pure Redux with Angular 2 and TypeScript
MIT License
71 stars 14 forks source link

can you include your favorite debugging workflow #3

Closed born2net closed 8 years ago

born2net commented 8 years ago

It would be awesome if you include your favorite workflow as far as debugging, do you use live sever or express? which arguments do you use... with gulp? or do you use ts watch or others?

tx as always

seen

born2net commented 8 years ago

will share my ui asap, check this https://youtu.be/RQSRKi3VZ3I

born2net commented 8 years ago

here you go:

aaa

born2net commented 8 years ago

so basically webstorm compiles so I can see the errors in the TS tab inside webstorm and of of course I also compile inside the browser tx to jspm, works awesome!

born2net commented 8 years ago

I also recommend you checkout: https://github.com/born2net/ng2Boilerplate/blob/master/gulpfile.js did some clever stuff like restarting local web server every 10min using forever for best performance and being able to run gulp development --restart with flag so it does not launch a new browser every 10min also found this config to be best for live server:

gulp.task('x_open_server_development', ['x_watch_source'], function () {
    process.stdout.write('Starting browserSync and superstatic...\n');
    browserSync({
        port: 8080,
        open: false,
        files: ['index.html', '**/*.ts'],
        notify: true,
        reloadDebounce: 400,
        server: {
            baseDir: './',
            directory: true
        }
    });
    opn('http://localhost:8080/src/public/index.html')
});

after a lot of trial and error... hope that helps

rubyboy commented 8 years ago

Good stuff in there!! I'll definitely dig in and copy some of that to our own projects, if you don't mind :) Thanks heaps.

born2net commented 8 years ago

are kidding.. baroor... :)

born2net commented 8 years ago

so did moving to Intelij worked out better? I know you have a lot of experience with jspm, I am trying to load a global jquery lib but can't seem to get it to export the global

here: http://stackoverflow.com/questions/35422441/loading-jspm-bootbox-as-shim-global-member

any tips?

rubyboy commented 8 years ago

Still flip flopping between IntelliJ and Atom. Not sure I like configuring the exclusion per project - it's a bit annoying - but it may be just worth it for the awesome autocompletion. IntelliJ is by far the best IDE around, so I'm not giving up that easily :)

Couldn't find the page you've linked. Have you found a solution? I did something similar when loading MaterializeCSS in the angular2-materialize library: https://github.com/InfomediaLtd/angular2-materialize You can add a shim to it when installing the dependency that needs it, like this:

jspm install materialize=github:Dogfalo/materialize -o "{'main': 'js/materialize','shim': {'js/materialize': {'deps': ['jquery','../css/materialize.css!'],'exports': '$'}},'dependencies': {'jquery': 'github:components/jquery','css': 'github:systemjs/plugin-css'}}"
born2net commented 8 years ago

ha got it tx

born2net commented 8 years ago

I improved a bit on your base class for Actions so I don't have to pass the store all the time, instead I inject it on the extending class..

export class Actions {

    private m_appStore:AppStore;

    constructor(i_appStore?:AppStore) {
        if (i_appStore)
            this.m_appStore = i_appStore;
    }

    public createDispatcher(action:(...n:any[])=>any, appStore?:AppStore):(...args)=>void {
        if (!appStore && !this.m_appStore)
            throw new Error('cant find AppStore for Actions base class');
        appStore = appStore || this.m_appStore;
        return (...n)=>appStore.dispatch(action.call(this, ...n))
    }
}

this way I can do manual dispatch/trigger in one short(er) command if need be:

    this.appdbAction.createDispatcher(this.appdbAction.authenticateUser)(i_user, i_pass);
rubyboy commented 8 years ago

Great idea!

Here's the final code to commit:

export class Actions {

    private appStore:AppStore = null;

    constructor(appStore?:AppStore) {
        if (appStore) this.appStore = appStore;
    }

    public createDispatcher(action:(...n:any[])=>any, appStore?:AppStore):(...n)=>void {
        if (!appStore && !this.appStore) throw new Error("Can't find AppStore for dispatching action");
        appStore = appStore || this.appStore;
        return (...n)=>appStore.dispatch(action.call(this, ...n))
    }

}

Would you like to create a pull request and I'll get that in? Happy to check the above in myself, but to be fair to you I think it should be on your name :)

born2net commented 8 years ago

ha np,hosnstly I never did a PR, not sure on the process through webstom, no worries glad to help you back for all your support...

rubyboy commented 8 years ago

No worries. Will do. Let's agree that next time you come up with a cool improvement I'll help you out with creating your first PR?

I recommend this free course on Egghead explaining the basics of Github and PR's: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github Also, even a better one, about creating an open source library: https://egghead.io/series/how-to-write-an-open-source-javascript-library

Both are by the awesome @kentcdodds

born2net commented 8 years ago

sweet tx!

kentcdodds commented 8 years ago

Thanks for the shoutout @rubyboy! I hope this helps you @born2net! :+1: