Skip to content

Instantly share code, notes, and snippets.

@vchimev
vchimev / livesync-navigation.ts
Last active February 7, 2019 18:07 — forked from vakrilov/livesync-navigation.ts
NativeScript-Angular HMR
import { NgZone } from "@angular/core";
import { Router } from "@angular/router";
import { onBeforeLivesync, onAfterLivesync } from "nativescript-angular/platform-common";
import { RouterExtensions } from "nativescript-angular/router";
let cachedUrl: string;
onBeforeLivesync.subscribe(moduleRef => {
console.log("#### onBeforeLivesync");
if (moduleRef) {
const router = <Router>moduleRef.injector.get(Router);
ROOT FRAME SCENARIOS:
1. Show modal dialog with frame
1.1. Navigate to modal second page within modal dialog
1.1.1. Go back
1.2. Show nested modal dialog
1.2.1. Close nested modal dialog
1.3. Close modal dialog
2. Show modal dialog
2.1. Show nested modal dialog
2.1.1. Close nested modal dialog

One of the main goals of tns-core-modules@4.0 is to enable more flexible composition of UI. Let's start with some history. Before 4.0 we create Frame control for you (check application.ios.ts and frame.android.ts). Frame control allows you to do navigation forward or backward. While this is convenient it introduce other issues that can't be workaround easliy. For example if you want to have TabView in all pages you have to include it in the xml and set its selectedIndex so that once you navigate to different page a correct TabViewItem is selected. This leads to several problems:

  • parse more xml
  • increase memory usage
  • increase loading time

Same issues apply if you want to have SideDrawer control as a root component.

So in order to resolve these starting with 4.0 applicat

@vchimev
vchimev / publish
Created August 9, 2017 14:44 — forked from sis0k0/publish
simple bash script for npm packages publish prepare
#!/bin/bash
set -e
# release defaults to patch (last number in semver)
RELEASE="patch" && [ -n "$1" ] && RELEASE=$1
# cut the release
VERSION=$(npm --no-git-tag-version version $RELEASE | sed 's/v//')
git add package.json
git commit -m "release: cut the $VERSION release"