-
The documentation for using NativeScript with Angular 2 is pretty sparse. A lot of what I learned came from various repository readme's and logged GitHub Issues. For the most part however, it's quite similar to regular Angular2 development except that instead of using HTML to template UI elements, you now have to use NativeScript's XML templating language.
-
NativeScript itself has decent documentation so it wasn't difficult to use it's provided APIs. In terms of application structure, it feels as if it plays pretty well with Angular2 and I would imagine that you could keep a lot of the same structure between a web and native Angular2 application. NativeScript also seems to provide a more bare bones approach to bridging native mobile APIs. Personally I felt like this could be a positive, as some of the abstraction with react-native can make it difficult to get fine tuned control over components. NativeScript has the benefit of being a 'write once, run anywhere' fram
This file contains 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 { useDispatch, useSelector } from 'react-redux'; | |
export const useStateConnection = (stateMap, actionMap) => { | |
const mapState = {}; | |
const mapDispatch = {}; | |
// Map state keys to redux store | |
if (stateMap) { | |
Object.keys(stateMap).forEach(key => { | |
mapState[key] = useSelector(stateMap[key]); |
This file contains 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 from 'react'; | |
import { Animated, Easing } from 'react-native'; | |
import { LinearGradient as SvgLinearGradient, Stop } from 'react-native-svg'; | |
const AnimatedStop = Animated.createAnimatedComponent(Stop); | |
export class AnimatedLinearGradient extends React.Component<LinearGradientProps> { | |
constructor(props) { | |
super(props); |
This file contains 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
componentDidUpdate(oldProps) { | |
Object.keys(oldProps).forEach((key) => { | |
if (typeof this.props[key] === 'undefined') { | |
console.log(`Prop '${key} removed`); | |
} | |
if (oldProps[key] !== this.props[key]) { | |
console.log(`Prop '${key}' changed from ${oldProps[key]} -> ${this.props[key]}`); | |
} | |
}); | |
Object.keys(this.props).forEach((key) => { |
This file contains 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
/***************************************************************************************** | |
* | |
* Imports | |
* | |
******************************************************************************************/ | |
var express = require('express'); | |
var bodyParser = require('body-parser'); | |
/***************************************************************************************** |
This file contains 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
from pytube import YouTube | |
from sys import argv | |
from os import system | |
DOWLOAD_LOCATION = 'videos/' | |
MP3_LOCATION = 'mp3/' | |
src = argv[1] | |
if not(src): |
This file contains 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
#!usr/bin/env python | |
import RPi.GPIO as GPIO | |
import time | |
import urllib2 | |
import threading | |
import json | |
GPIO.setwarnings(False) | |
# Use the Broadcom SOC channe numbering system for the outputs |
This file contains 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 set(obj, property, value) { | |
var properties = R.split('.',property); | |
var context = obj; | |
var i; | |
for(i=0; i < properties.length -1; i++) { | |
context = context[properties[i]]; | |
} | |
context[properties[i]] = value; | |
} |
This file contains 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
/** | |
* The examples provided by Facebook are for non-commercial testing and | |
* evaluation purposes only. | |
* | |
* Facebook reserves all rights not expressly granted. | |
* | |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL | |
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |