Warning: Undefined variable $header_class in /var/www/wpss/wp-content/themes/portum/header.php on line 20

Warning: Trying to access array offset on null in /var/www/wpss/wp-content/themes/portum/inc/helpers/class-portum-helper.php on line 214
Steve Strugnell – Back-end Developer, Front-end developer, Infrastructure & Cloud
Image of TypeScript and Angular code

Debugging Angular Lifecycle Events with Class Decorators

We’ve all been there – you’re working on an Angular component and things aren’t quite working out as you expect. You need to quickly see what’s happening with your inputs, or maybe your component is being rendered conditionally and you need to understand at what point it’s being initialised and destroyed on the page.

Most of the time you end up doing something like this:

public ngOnDestroy(): void {
  console.log('SheepStacker component destroyed');
}

public ngOnChanges(changes: SimpleChanges): void {
  for (const prop in changes) {
    console.log(prop, changes.prop.currentValue);
  }
}

However there are problems with this code, and it’s a pain to write out each time.

(Continue reading…)

Image of PHP code

Making PHP functions fun again (with PHPStorm Live Templates)

As a full-stack web developer I spend a lot of time switching between back-end and front-end code. When you’ve been working in TypeScript or JavaScript ES6, coming back to PHP and it’s lack of short form for anonymous functions and closures is a real frustration.

Image of TypeScript closure code

TypeScript closure

Image of PHP closure code

PHP Closure

Whilst we all continue to wait for the progress of the PHP RFC for arrow functions, fortunately there are some tricks you can use to make it a lot less painful for creating these functions in PHP.
(Continue reading…)