Socket
Socket
Sign inDemoInstall

inversify-hooks

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inversify-hooks - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

4

dist/index.d.ts
export * from 'inversify-props';
import { useService } from './use-service.hook';
export { useService };
import { useContainer } from './use-service.hook';
export { useContainer };

@@ -8,3 +8,3 @@ "use strict";

var use_service_hook_1 = require("./use-service.hook");
exports.useService = use_service_hook_1.useService;
exports.useContainer = use_service_hook_1.useContainer;
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

export declare function useService<T>(id: string): T;
export declare function useContainer<T>(id: string | symbol): T;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var inversify_props_1 = require("inversify-props");
function useService(id) {
function useContainer(id) {
return inversify_props_1.container.get(id);
}
exports.useService = useService;
exports.useContainer = useContainer;
//# sourceMappingURL=use-service.hook.js.map
{
"name": "inversify-hooks",
"version": "1.2.1",
"version": "1.3.0",
"description": "Wrapper of inversify-props to inject your dependencies in the components, made with TypeScript using hooks.",

@@ -25,5 +25,8 @@ "main": "dist/index.js",

],
"peerDependencies": {
"reflect-metadata": "0.1.12"
},
"dependencies": {
"inversify-props": "^1.0.0"
"inversify-props": "^1.3.0"
}
}

@@ -1,2 +0,2 @@

# Inversify Props
# Inversify Hooks
This package is a wrapper of [inversify-props](https://github.com/ckgrafico/inversify-props) to simplify how inject your dependencies in components with hooks.

@@ -10,5 +10,7 @@

![logo](https://i.imgur.com/syVbzU6.gif)
## Installation
```
npm install --save inversify-hooks
npm install --save inversify-hooks reflect-metadata@0.1.12
```

@@ -19,28 +21,24 @@

container.addSingleton<IService1>(Service1);
container.addSingleton<IService2>(Service2);
function ExampleComponent() {
const service1 = useService<IService1>('IService1');
const service1 = useContainer<IService1>(cid.IService1);
}
```
## Why we made this package
You can learn more about why we made this packages in the [original repo](https://github.com/ckgrafico/inversify-props#why-we-made-this-package).
## You can also use any ID that you prefer
```
container.addSingleton<IService1>(Service1, 'MyService1');
## How register a dependency
If you're not familizared of how to register dependencies, [check the docs](https://github.com/ckgrafico/inversify-props#how-register-a-dependency).
## How to use in your components
Once your dependencies are registered in the container, is simple use the hook to get the dependency.
```
function ExampleComponent() {
const service1 = useService<IService1>('IService1');
const service1 = useContainer<IService1>('MyService1');
}
```
## How to configure uglify
If you're using uglify or similar you need to [configure well the plugin](https://github.com/ckgrafico/inversify-props#how-to-configure-uglify).
## Why we made this package
You can learn more about why we made this packages in the [original repo](https://github.com/ckgrafico/inversify-props#why-we-made-this-package).
## Next steps
- Remove id param, and use `magic id` like in inversify-props.
## How register a dependency
If you're not familizared of how to register dependencies, [check the docs](https://github.com/ckgrafico/inversify-props#how-register-a-dependency).
## How to configure Uglify or Terser
f you're using Uglify or Terser you need to configure well the plugin, [check the docs](https://github.com/ckgrafico/inversify-props#how-to-configure-uglify-or-terser).
export * from 'inversify-props';
import { useService } from './use-service.hook';
import { useContainer } from './use-service.hook';
export {
useService
useContainer
};

@@ -0,0 +0,0 @@ {

import { container } from 'inversify-props';
export function useService<T>(id: string): T {
export function useContainer<T>(id: string | symbol): T {
return container.get(id);
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc