Socket
Socket
Sign inDemoInstall

framework

Package Overview
Dependencies
22
Maintainers
4
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    framework

Framework for TypeScript applications


Version published
Weekly downloads
244
increased by525.64%
Maintainers
4
Created
Weekly downloads
 

Readme

Source

framework

Simple framework for React, TypeScript and effector applications.

Installation

npm install framework

Usage

// index.ts
import { createBrowserApplication } from 'framework';
import { createEvent } from 'effector';

import * as navigation from 'entities/navigation';
import { routes } from './pages';

const applicationLoaded = createEvent()

const app = createBrowserApplication({
  routes,
  ready: applicationLoaded,
  domain: navigation.navigationDomain
  // domain is optional
  // for debug/logging
});

// connect local route events

forward({
  from: navigation.historyPush,
  to: app.navigation.historyPush
})
forward({
  from: navigation.historyPushSearch,
  to: app.navigation.historyPushSearch
})
forward({
  from: navigation.historyReplace,
  to: app.navigation.historyReplace
})
// some-page/contract.ts
import { createHatch } from 'framework';

import { navigationDomain } from 'entities/navigation';

export const hatch = createHatch(navigationDomain);
// domain is optional
// for debug/logging
// some-page/index.tsx
import { guard, createDomain } from 'effector';
import { withHatch } from 'framework';

import { historyPush } from 'entities/navigation';
import { $isAuthenticated } from 'entities/session';

import { hatch } from './contract';

export const Page = withHatch(hatch, () => {
  //...
});

guard({
  source: hatch.enter,
  filter: $isAuthenticated.map((is) => !is),
  target: historyPush.prepend(() => '/login')
});

Keywords

FAQs

Last updated on 08 Apr 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc