Friday, 1 September 2017

Happy Birthday NP8080!

NP8080 turns 1 year old! Yes it was just over a year ago that I decided to combine a TextArea + Local Storage to make a little app. It's grown a lot and been a good project to try out new features and packages. I've found it a useful daily tool too from simple notes, examining stacktraces and composing web posts etc.

With Dart 2.0 coming, Angular Dart 5 and web browsers advancing, it looks like there'll be another year of text editor coding ahead.

Saturday, 22 July 2017

Diving Into Angular 4 Dart Alpha 1

Angular Dart 4 Alpha was recently released and I was keen to try it out. There's quite a few changes as it becomes increasingly more Dart-ified and broken away from its Typescript heritage.

My hobby project NP8080, as ever, is my guinea pig for such upgrades. It was almost entirely painless - we can forgive the one time rename of the package from Angular2 to plain Angular! Building is slightly slower/heavier (there's a lot going on) but this is being worked on.

The standout feature for me is the component inheritance of attributes such as @input. There's a lot of components in my app that have common functions (dialogs mainly) but being unable to have a hierarchy to share stuff meant that... well things got a bit messy and copy-pastey!

With the new release I spent a happy time creating my base classes and shifting the functionality around. The joy of deleting hundreds of lines of code!

So the class structure ended up something like this:

     Base Component Class                    Base Component Class 
             ||                                       ||
     Editor Component Class                Another GUI Control Class
             ||
   1 Particular Dialog Class

Even better was the Dependency Injection, the base classes could have services injected into them from the derived classed and they could still be marked final too. Very nice! Slight downside is the declarations:

  GenerateDialogComponent(
      TextProcessingService newTextProcessingService,
      TextareaDomService newTextareaDomService,
      ThemeService newThemeService,
      EventBusService newEventBusService)
      : super(newTextProcessingService, newTextareaDomService, newThemeService,
            newEventBusService) {
   ...
  }

It's a bit cluttering annoying to declare a variable like newTextProcessingService that gets passed immediately to the super call and never referenced again. I wonder if the following would be a possible language change? Seems a lot cleaner and clearer to me and should cover most cases.

  @InjectSuperParameters
  GenerateDialogComponent() : super(textProcessingService, 
              textareaDomService, 
              themeService,
              eventBusService) {
   ...
  }

Anyway, going forward creating a new dialog or control should be half the work. Sounds good! Look forward to the next Alpha/Beta.

Monday, 26 June 2017

Dart SDK and Dartium 1.24.2 Chocolatey Packages for Windows

Chocolatey is a package manager for Windows similar to Linux's apt-get, based on Microsoft's Nuget tool and Powershell scripting language. It works from the command-line and from a WPF GUI interface.

You can install unmoderated versions by specifiying the install version during installation.
Chocolatey has also been updated with versions 1.24.2
Command line installation:
choco uninstall dart-sdk

choco install -y dart-sdk  -version 1.24.2
To verify you have the right version on your path.
dart --version
Dart VM version: 1.24.2 (Thu Jun 22 08:55:56 2017) on "windows_x64"

Command line installation:
choco uninstall dartium

choco install -y dartium  -version 1.24.2

Saturday, 17 June 2017

A Multiplicity of Singleton Services

Angular Services are singletons right? Google it and you will get plenty of pages saying they are. Well sometimes they are and sometimes they are not!

I was working on a service that didn't seem to be working. To debug, I put a print statement in the constructor and I received 2 messages. So what's happening? Turns out to be down to Providers

Suppose you have a component and you want to use a service, you may have declared it in each component like this:

providers: const [TextProcessingService]

This actually creates a new instance before injecting it into your component.

So say we only want one instance ever? How do we do it? First step, delete that Providers declaration. Next declare at the bootstrap level:

  bootstrap(
      AppComponent, [TextProcessingService]
  );

Hope this blog post clears up confusion for anyone else. It is actually quite a powerful feature, allowing you to keep services and components totally separate.

Thursday, 15 June 2017

Dart SDK and Dartium 1.24.1 Chocolatey Packages for Windows

Chocolatey is a package manager for Windows similar to Linux's apt-get, based on Microsoft's Nuget tool and Powershell scripting language. It works from the command-line and from a WPF GUI interface.

You can install unmoderated versions by specifiying the install version during installation.
Chocolatey has also been updated with versions 1.24.1
Command line installation:
choco uninstall dart-sdk

choco install -y dart-sdk  -version 1.24.1
To verify you have the right version on your path.
dart --version
Dart VM version: 1.24.1 (Wed Jun 14 07:53:19 2017) on "windows_x64"

Command line installation:
choco uninstall dartium

choco install -y dartium  -version 1.24.1

Tuesday, 13 June 2017

Dart SDK and Dartium 1.24.0 Chocolatey Packages for Windows

Chocolatey is a package manager for Windows similar to Linux's apt-get, based on Microsoft's Nuget tool and Powershell scripting language. It works from the command-line and from a WPF GUI interface.

You can install unmoderated versions by specifiying the install version during installation.
Chocolatey has also been updated with versions 1.24.0
Command line installation:
choco uninstall dart-sdk

choco install -y dart-sdk  -version 1.24.0
To verify you have the right version on your path.
dart --version
Dart VM version: 1.24.0 (Mon Jun 12 08:37:04 2017) on "windows_x64"

Command line installation:
choco uninstall dartium

choco install -y dartium  -version 1.24.0