Towards A Clean Architecture for Ionic 2 Apps

 
1 Kudos
Don't
move!

I have one requirement for my new Ionic 2 app: The core needs to work without Ionic 2. It will be released as native apps for Android and iOS, but also as a Single-Page-App (SPA).

Ionic 2 is optimized for iOS and Android and not made for Web apps. Thus, I need to separate as much logic as possible from Ionic 2 and create a core application that can be interacted with through an Ionic 2 layer or an SPA.

This requirement forces me to think about a clean architecture when writing Ionic 2 apps.

I haven’t found the perfect solution yet, but stumbled across a few interesting ideas, concepts and articles that I want to share with you.

Even if you won’t make a Web-app, I hope you can take a few ideas from this post.

Continue reading Towards A Clean Architecture for Ionic 2 Apps

Hybrid app development is complicated

 
2 Kudos
Don't
move!

The other day I read on Hacker News something like:

I wanted to get into Web Development. Is it really that ugly, hard, and annoying?

I thought: What’s the problem? It ain’t that bad, but to be honest, it really is quite difficult.

Web development in 2016 means: Doing a lot of JavaScript. Setting up your JavaScript stack takes time and knowledge and sure, you can get away with a bit of jQuery and Vanilla JS.

Since I decided to make the new version of my app entirely hybrid, I’m intrigued by Ionic 2, Angular 2 and TypeScript.

Sure, you can punch out a stupid small app in no time with Ionic 2, but something with a bit more complexity requires a few more brain cycles. Obviously, my new app has to be maintainable, needs sync across devices, I want a web UI in addition to the mobile apps and all of a sudden, I find myself in the same mess as the guy who asked on Hacker News.

Doing a hybrid mobile app in 2016 means to learn:

Continue reading Hybrid app development is complicated

How to Draw Sharp Lines on a HTML5 Canvas for Retina Displays

 
5 Kudos
Don't
move!

Two ways to get 1px wide sharp and crisp lines for retina displays:

  • Scale the canvas to twice the size (context.scale(2,2);) and then draw a 1px wide line like so: context.lineWidth=0.5
  • Use all device pixels and draw the image twice the size. This is the approach I focus on in this blog post.

Here is how to draw super sharp lines on an HTML5 canvas for retina displays: Continue reading How to Draw Sharp Lines on a HTML5 Canvas for Retina Displays

React Native: Cannot connect device to packager (npm start)

 
5 Kudos
Don't
move!

I just started to give React Native a try. I followed the tutorial, changed localhost to my MacBook’s IP address, but for some reason, I couldn’t connect my device (iPhone 5) to the React packager server, which I started via npm start in the React project’s root directory.

The error in Xcode was a timeout:

http://192.168.1.5:8081/index.ios.bundle?platform=ios&dev=true&hot=true
2016-06-22 17:03:37.615 [error][tid:main][RCTWebSocketManager.m:84] WebSocket connection failed with error Error Domain=NSPOSIXErrorDomain Code=60 "Operation timed out"

I noticed that I couldn’t open the packager server from Safari on the device as well (http://192.168.1.5:8081), which I found odd.

Then I tried to find a solution for the search term ios safari connect local webserver and this is the answer:

http://stackoverflow.com/questions/12657651/connect-device-to-mac-localhost-server

If your iOS device can’t connect to the React Native packager server, although everything is set up flawlessly, JUST DISABLE AND ENABLE YOUR MAC’S WIFI.

Stupid thing, but it works. I just wasted an hour on this 😤

Let’s make a Telegram Bot with PHP

 
132 Kudos
Don't
move!

I spend a few days creating a Telegram bot for my SaaS. It serves as a convenient way for my users to enter data. The bot isn’t smart at all, but at its core is a regex pattern matcher which allows entering various health-related data points.

While the Telegram docs try to give you an easy start, I found them lacking. With this article, I want to fill some gaps.

Continue reading Let’s make a Telegram Bot with PHP

Value Objects in Laravel 5 with Eloquent Done Right

 
16 Kudos
Don't
move!

Update April 25th, 2016: I don’t use Value Objects in Laravel anymore. Here’s why.

One idea of Value Objects is to restrict what a programmer can do within the model. For example, an EmailAddress value object cannot be set to an invalid email address.

The advantage is: Validation and consistency of the domain model.

With Laravel however, there are a few things to think about and it took me a while to figure out a good solution.

tl;dr:

  • Use a Mutator to enforce the type of a Value Object
  • Store your Value Object as native value in your Eloquent model
  • Use an Accessor to create a Value Object from the native value
  • Implement __toString() in your Value Object to allow toArray()
  • Use the JsonSerializable interface to allow toJson() conversion
  • Plus: Do all of this automatically without Mutators and Accessors

Continue reading Value Objects in Laravel 5 with Eloquent Done Right

Ejecta & Impact.js – Disable Game Center & In-App Purchase Capabilities

 
0 Kudos
Don't
move!

I made an app with Impact.js that did neither require the Game Center, nor In-App Purchases. If you disable the capabilities in your Xcode project, you’ll notice that the build fails with 11 linker errors:
Continue reading Ejecta & Impact.js – Disable Game Center & In-App Purchase Capabilities