This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as services from './module'; | |
| const serviceModule = angular.module('app.services', []); | |
| // Automatically register each service. | |
| Object.keys(services).forEach(key => { | |
| if(!services[key].__service) { | |
| console.warn(`Service ${key} is missing the @Service decorator.`); | |
| return; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Service(name) { | |
| return target => { | |
| target.__service = { name }; | |
| return target; | |
| } | |
| } | |
| function Controller(name, stateOpts) { | |
| return target => { | |
| target.__controller = { name, stateOpts }; // stateOpts get passed to $stateProvider during registration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Inject } from 'decorators'; | |
| function factoryize(directive) { | |
| return directive.$inject | |
| ? Inject(...directive.$inject)((...dependencies) => new directive(...dependencies)) | |
| : () => new directive(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Inject, Directive } from 'decorators'; | |
| @Inject('$scope', '$compile') | |
| @Directive('myDirective') | |
| class MyDirective { | |
| constructor($scope, $compile) { | |
| // ... | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Inject } from 'decorators'; | |
| import * as directives from './module'; | |
| function factoryize(directive) { | |
| return directive.$inject | |
| ? Inject(...directive.$inject)((...dependencies) => new directive(...dependencies)) | |
| : () => new directive(); | |
| } | |
| const directivesModule = angular.module('app.directives', []); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Service | |
| public class BatchServiceImpl { | |
| @Scheduled(cron = "your-cron-expression-here (example: */5 * * * * MON-FRI would execute on weekdays)") | |
| public void sendReport() { | |
| // ... | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component, PropTypes } from 'react' | |
| import { render } from 'react-dom' | |
| class Parent extends Component { | |
| static childContextTypes = { | |
| someContext1: PropTypes.object, | |
| someContext2: PropTypes.object | |
| } | |
| render() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react' | |
| function withContext(key, type) { | |
| return WrappedComponent => class ContextComponent extends Component { | |
| static contextTypes = { | |
| ...WrappedComponent.contextTypes, | |
| [key]: type | |
| } | |
| render() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component, PropTypes } from 'react' | |
| import { render } from 'react-dom' | |
| import withContext from './with-context' | |
| class Parent extends Component { | |
| static childContextTypes = { | |
| someContext1: PropTypes.object, | |
| someContext2: PropTypes.object | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function thread(arg, ...funcs) { | |
| return funcs.reduce((prev, func) => func(prev), arg) | |
| } | |
| export default thread |