<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pete Schuster</title>
	<atom:link href="http://peteschuster.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://peteschuster.com</link>
	<description>Philadelphia Front End Developer</description>
	<lastBuildDate>Sun, 21 Jan 2018 20:01:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.9.8</generator>
	<item>
		<title>High Praise for React and the React Ecosystem</title>
		<link>https://peteschuster.com/2017/10/high-praise-react-react-ecosystem/</link>
		<pubDate>Sun, 08 Oct 2017 12:59:42 +0000</pubDate>
		<dc:creator><![CDATA[Pete Schuster]]></dc:creator>
				<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[preact]]></category>
		<category><![CDATA[react]]></category>
		<category><![CDATA[redux]]></category>
		<category><![CDATA[webpack]]></category>

		<guid isPermaLink="false">https://peteschuster.com/?p=4177</guid>
		<description><![CDATA[<p>The React ecosystem provides the best developer experience I&#8217;ve ever used. Around 2 years ago, I got to work on a React/Redux/Webpack project. Prior to the project, I had tried&#8230;</p>
<p>The post <a rel="nofollow" href="https://peteschuster.com/2017/10/high-praise-react-react-ecosystem/">High Praise for React and the React Ecosystem</a> appeared first on <a rel="nofollow" href="https://peteschuster.com">Pete Schuster</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>The React ecosystem provides the best developer experience I&#8217;ve ever used. Around 2 years ago, I got to work on a React/Redux/Webpack project. Prior to the project, I had tried to learn React, but with so many new concepts like Webpack, ES6 syntax, and JSX, I was mainly scared away. It wasn&#8217;t until I got the opportunity to work on an existing codebase that I truly fell in love.</p>
<p>Working with <a href="https://webpack.js.org/" target="_blank" rel="noopener">Webpack</a> you get hot module reloading, ES6 module syntax, <a href="https://babeljs.io/" target="_blank" rel="noopener">babel</a>, eslint, and CSS style injection. With React/Redux, you get Redux Dev Tools, and principles of functional programming. This tooling is sorely missed when moving off to a legacy project without them.</p>
<p>The community surrounding React is very supportive. Whether its a full <a href="https://egghead.io/courses/getting-started-with-redux" target="_blank" rel="noopener">free course on Egghead.io</a> by Redux creator <a href="https://github.com/gaearon" target="_blank" rel="noopener">Dan Abramov</a>, or the thousands of questions and answers on Stack Overflow, the React community is thriving.</p>
<p>Mainly, I use <a href="https://github.com/facebookincubator/create-react-app" target="_blank" rel="noopener">create-react-app</a> and run the eject script to get up and running quickly. This provides me with the latest from the React/Webpack dev team. Lately, I&#8217;ve been using preact-compat as an alias in my Webpack config to benefit from the smaller file size of preact. create-react-app also adds offline first support with Service Worker, something I haven&#8217;t taken advantage of yet.</p>
<p>Finally, there was some issues with licensing recently with React, but that has since cleared up. My next personal project will be to rearchitecture my personal site using preact/webpack/redux and XHR requests to WordPress.</p>
<p>The post <a rel="nofollow" href="https://peteschuster.com/2017/10/high-praise-react-react-ecosystem/">High Praise for React and the React Ecosystem</a> appeared first on <a rel="nofollow" href="https://peteschuster.com">Pete Schuster</a>.</p>
]]></content:encoded>
			</item>
		<item>
		<title>Jasmine Testing Angular Controller with Service(s)</title>
		<link>https://peteschuster.com/2016/03/jasmine-testing-angular-controller-services/</link>
		<pubDate>Thu, 31 Mar 2016 14:01:30 +0000</pubDate>
		<dc:creator><![CDATA[Pete Schuster]]></dc:creator>
				<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[jasmine]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://peteschuster.com/?p=4161</guid>
		<description><![CDATA[<p>My experience with testing in Angular 1.x is with Jasmine and using Karma as a test runner. When I first started I struggled to figure out how to test a&#8230;</p>
<p>The post <a rel="nofollow" href="https://peteschuster.com/2016/03/jasmine-testing-angular-controller-services/">Jasmine Testing Angular Controller with Service(s)</a> appeared first on <a rel="nofollow" href="https://peteschuster.com">Pete Schuster</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>My experience with testing in Angular 1.x is with Jasmine and using Karma as a test runner. When I first started I struggled to figure out how to test a controller that had a dependency on a service that makes a call to an API. Below is an example of a service, controller and controller_spec as an example of how to structure a Jasmine test for a Angular controller with a service(s).</p>
<h3>Example Service #1:</h3>
<pre class="language-javascript line-numbers"><code>
angular.module('ActivityApp').service('PersonService', [
  '$resource',
  function ($resource) {
    'use strict';

    var Person = $resource('', null, {
      get: {
        method: 'GET',
        url: '/apis/person'
      }
    }));

    return Person;
  }
]);
</code></pre>
<h3>Example Service #2:</h3>
<pre class="language-javascript line-numbers"><code>
angular.module('ActivityApp').service('ActivityService', [
  '$resource',
  function ($resource) {
    'use strict';

    var Activity = $resource('', null, {
      query: {
        method: 'GET',
        url: '/apis/activity'
      }
    }));

    return Activity;
  }
]);
</code></pre>
<h3>Example Controller:</h3>
<pre class="language-javascript line-numbers"><code>
angular.module('ActivityApp').controller('PersonController', [
  '$scope',
  'PersonService',
  'ActivityService',
  function ($scope, PersonService, ActivityService) {
    'use strict';

    $scope.person = PersonService.get();
    $scope.activity = ActivityService.query();
    $scope.formData = {};

    $scope.resolveAll = function (response) {
      // response is an array of both resolved promises
    };

    $scope.save = function () {
      PersonService.save($scope.formData);
    };

    $q.all([$scope.person.$promise, $scope.activity.$promise]).then($scope.resolveAll);
  }]);
</code></pre>
<h3>Example Controller Spec:</h3>
<pre class="language-javascript line-numbers"><code>
describe('PersonController', function() {

  var $controller,
      $scope,
      PersonService,
      ActivityService;

  beforeEach(module('ActivityApp'));

  beforeEach(function () {
    PersonService = jasmine.createSpyObj('PersonService', [
      'get',
      'save'
    ]);

    ActivityService = jasmine.createSpyObj('ActivityService', [
      'query'
    ]);

    module(function ($provide) {
      $provide.value('PersonService', PersonService);
      $provide.value('ActivityService', ActivityService);
    });
  });

  beforeEach(inject(function(_$controller_, $rootScope) {
    $scope = $rootScope.$new();

    $controller = _$controller_('PersonController', {
      $scope: $scope
    });
  }));

  it('should be defined and call services', function() {
    expect($controller).toBeDefined();
    expect(PersonService.get).toHaveBeenCalled();
    expect(ActivityService.query).toHaveBeenCalled();
  });

  describe('$scope.save', function() {
    it('save formData to PersonService', function() {
      $scope.formData = { test: 'test' };
      $scope.save();
      expect(PersonService.save).toHaveBeenCalledWith({ test: 'test' });
    });
  });
});
</code></pre>
<p>The spec for the PersonController above asserts that when it is initiated, it will call both the PersonService and the ActivityService with their respective methods. Additionally, the <code>$scope.save</code> method will call the PersonService save method with the <code>$scope.formData</code> object.</p>
<p>It&#8217;s not the concern of the controller for what the service does. If the rest of your controller depends on the return value from the service, you can mock that out and create a promise for the other functions to react to.</p>
<h3>Example 2 Controller Spec:</h3>
<pre class="language-javascript line-numbers"><code>
describe('PersonController', function() {

  var $controller,
      $scope,
      PersonService,
      ActivityService
      PersonGetPromise,
      ActivityQueryPromise;

  beforeEach(module('ActivityApp'));

  beforeEach(function () {
    PersonService = jasmine.createSpyObj('PersonService', [
      'get',
      'save'
    ]);

    ActivityService = jasmine.createSpyObj('ActivityService', [
      'query'
    ]);

    module(function ($provide) {
      $provide.value('PersonService', PersonService);
      $provide.value('ActivityService', ActivityService);
    });
  });

  beforeEach(inject(function(_$controller_, $rootScope, $q) {
    PersonGetPromise = $q.defer();
    ActivityQueryPromise = $q.defer();

    PersonService.get.and.returnValue({ $promise: PersonGetPromise.promise });
    ActivityService.query.and.returnValue({ $promise: ActivityQueryPromise.promise });

    PersonGetPromise.resolve('MOCK DATA');
    ActivityQueryPromise.resolve('MOCK DATA');

    $scope = $rootScope.$new();

    $controller = _$controller_('PersonController', {
      $scope: $scope
    });
  }));

  it('should be defined and call services', function() {
    expect($controller).toBeDefined();
    expect(PersonService.get).toHaveBeenCalled();
    expect(ActivityService.query).toHaveBeenCalled();
  });

  describe('$scope.save', function() {
    it('save formData to PersonService', function() {
      $scope.formData = { test: 'test' };
      $scope.save();
      expect(PersonService.save).toHaveBeenCalledWith({ test: 'test' });
    });
  });
});
</code></pre>
<p>Now both promises have resolved without making a call to the external API. Instead of resolving the promises in the before each, you could also resolve then in the <code>it()</code> block or in another <code>beforeEach()</code> in a lower <code>describe()</code> block. This would allow you to create tests with different return values or with a rejected promise to test error cases.</p>
<p>The post <a rel="nofollow" href="https://peteschuster.com/2016/03/jasmine-testing-angular-controller-services/">Jasmine Testing Angular Controller with Service(s)</a> appeared first on <a rel="nofollow" href="https://peteschuster.com">Pete Schuster</a>.</p>
]]></content:encoded>
			</item>
		<item>
		<title>Waiting for Promises to Resolve in Angular 1.x</title>
		<link>https://peteschuster.com/2016/03/waiting-promises-resolve-angular-1-x/</link>
		<pubDate>Thu, 24 Mar 2016 00:38:38 +0000</pubDate>
		<dc:creator><![CDATA[Pete Schuster]]></dc:creator>
				<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[$q]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[promises]]></category>

		<guid isPermaLink="false">http://peteschuster.com/?p=4157</guid>
		<description><![CDATA[<p>Been spending a lot of time in Angular recently. I really enjoy using services with promises to get data back from an API. Sometimes you&#8217;ll have cause to want to&#8230;</p>
<p>The post <a rel="nofollow" href="https://peteschuster.com/2016/03/waiting-promises-resolve-angular-1-x/">Waiting for Promises to Resolve in Angular 1.x</a> appeared first on <a rel="nofollow" href="https://peteschuster.com">Pete Schuster</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Been spending a lot of time in Angular recently. I really enjoy using services with promises to get data back from an API. Sometimes you&#8217;ll have cause to want to wait for 2 or more promises to resolve before you act on the data that comes back. Angular provides the <a href="https://docs.angularjs.org/api/ng/service/$q#all" target="_blank">$q.all</a> to help you achieve this.</p>
<h3>Example Service #1:</h3>
<pre class="language-javascript line-numbers"><code>
angular.module('ActivityApp').service('PersonService', [
  '$resource',
  function ($resource) {
    'use strict';

    var Person = $resource('', null, {
      get: {
        method: 'GET',
        url: '/apis/person'
      }
    }));

    return Person;
  }
]);
</code></pre>
<h3>Example Service #2:</h3>
<pre class="language-javascript line-numbers"><code>
angular.module('ActivityApp').service('ActivityService', [
  '$resource',
  function ($resource) {
    'use strict';

    var Activity = $resource('', null, {
      query: {
        method: 'GET',
        url: '/apis/activity'
      }
    }));

    return Activity;
  }
]);
</code></pre>
<h3>Example Controller:</h3>
<pre class="language-javascript line-numbers"><code>
angular.module('ActivityApp').controller('PersonController', [
  '$scope',
  'PersonService',
  'ActivityService',
  function ($scope, PersonService, ActivityService) {
    'use strict';

    $scope.person = PersonService.get();
    $scope.activity = ActivityService.query();

    $scope.resolveAll = function (response) {
      // response is an array of both resolved promises
    };

    $q.all([$scope.person.$promise, $scope.activity.$promise]).then($scope.resolveAll);
  }]);

</code></pre>
<p>Now in the <code>$scope.resolveAll</code> function you can act on the data and be sure that you have access to sets of data.</p>
<p>The post <a rel="nofollow" href="https://peteschuster.com/2016/03/waiting-promises-resolve-angular-1-x/">Waiting for Promises to Resolve in Angular 1.x</a> appeared first on <a rel="nofollow" href="https://peteschuster.com">Pete Schuster</a>.</p>
]]></content:encoded>
			</item>
		<item>
		<title>CSS Text Align Start and End</title>
		<link>https://peteschuster.com/2015/08/css-text-align-start-and-end/</link>
		<pubDate>Tue, 18 Aug 2015 10:18:13 +0000</pubDate>
		<dc:creator><![CDATA[Pete Schuster]]></dc:creator>
				<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[Today I Learned]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://peteschuster.com/?p=4135</guid>
		<description><![CDATA[<p>Today I learned about two experimental values for the CSS property text-align. The rules text-align: start; The same as left if direction is left-to-right and right if direction is right-to-left.&#8230;</p>
<p>The post <a rel="nofollow" href="https://peteschuster.com/2015/08/css-text-align-start-and-end/">CSS Text Align Start and End</a> appeared first on <a rel="nofollow" href="https://peteschuster.com">Pete Schuster</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Today I learned about two experimental values for the CSS property <code>text-align</code>.</p>
<h3>The rules</h3>
<ul>
<li><code>text-align: start;</code><br />
The same as left if direction is left-to-right and right if direction is right-to-left.</li>
<li><code>text-align: end;</code><br />
The same as right if direction is left-to-right and left if direction is right-to-left.</li>
</ul>
<p>What makes these rules helpful is that you don&#8217;t need to specify left or right alignment which helps with internationalization. Content with adjust automatically to users&#8217; language preferences that are <code>RTL</code> or <code>LTR</code>.</p>
<p>Browser support for these values is pretty high, missing only IE and Opera.</p>
<h3>Bonus</h3>
<p>Today I also learned that <code>text-align</code> is actually a shorthand property for <code>text-align-all</code> and <code>text-align-last</code> properties.</p>
<h5>Sources</h5>
<p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/text-align">https://developer.mozilla.org/en-US/docs/Web/CSS/text-align</a><br />
<a target="_blank" href="https://drafts.csswg.org/css-text-3/#text-align-property">https://drafts.csswg.org/css-text-3/#text-align-property</a><br />
<a target="_blank" href="https://drafts.csswg.org/css-text-3/#text-align-all-property">https://drafts.csswg.org/css-text-3/#text-align-all-property</a><br />
<a target="_blank" href="https://drafts.csswg.org/css-text-3/#text-align-last-property">https://drafts.csswg.org/css-text-3/#text-align-last-property</a></p>
<p>The post <a rel="nofollow" href="https://peteschuster.com/2015/08/css-text-align-start-and-end/">CSS Text Align Start and End</a> appeared first on <a rel="nofollow" href="https://peteschuster.com">Pete Schuster</a>.</p>
]]></content:encoded>
			</item>
	</channel>
</rss>
