🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

react-stream-bloc

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-stream-bloc - npm Package Compare versions

Comparing version
3.0.0
to
3.0.1-rm.1
+36
-3
lib/index.d.ts
import * as react_jsx_runtime from 'react/jsx-runtime';
import { ReactElementLike } from 'prop-types';
import * as React from 'react';
import { CookieAttributes } from 'js-cookie';
import { Observable } from 'rxjs';

@@ -26,5 +25,39 @@

interface AuthProps {
/**
* Define when the cookie will be removed. Value can be a Number
* which will be interpreted as days from time of creation or a
* Date instance. If omitted, the cookie becomes a session cookie.
*/
expires?: number | Date | undefined;
/**
* Define the path where the cookie is available. Defaults to '/'
*/
path?: string | undefined;
/**
* Define the domain where the cookie is available. Defaults to
* the domain of the page where the cookie was created.
*/
domain?: string | undefined;
/**
* A Boolean indicating if the cookie transmission requires a
* secure protocol (https). Defaults to false.
*/
secure?: boolean | undefined;
/**
* Asserts that a cookie must not be sent with cross-origin requests,
* providing some protection against cross-site request forgery
* attacks (CSRF)
*/
sameSite?: "strict" | "Strict" | "lax" | "Lax" | "none" | "None" | undefined;
/**
* An attribute which will be serialized, conformably to RFC 6265
* section 5.2.
*/
[property: string]: any;
}
declare const auth: (key: string) => string | undefined;
declare const setAuth: (key: string, data: string, options?: CookieAttributes) => string | undefined;
declare const removeAuth: (key: string, options?: CookieAttributes) => boolean;
declare const setAuth: (key: string, data: string, options?: AuthProps) => string | undefined;
declare const removeAuth: (key: string, options?: AuthProps) => boolean;
declare const getStore: (key: string, session?: boolean) => any;

@@ -31,0 +64,0 @@ declare const setStore: (key: string, data: any, session?: boolean) => boolean;

+1
-1
{
"name": "react-stream-bloc",
"version": "3.0.0",
"version": "3.0.1-rm.1",
"private": false,

@@ -5,0 +5,0 @@ "author": "Blencm",

@@ -31,4 +31,6 @@ # `react-stream-bloc`

## Example of use in javascript and typescript
## Usage example BlocBuilder
<a href="https://codesandbox.io/s/react-stream-bloc-example-qk3kjy"><img src="https://uploads.codesandbox.io/uploads/user/193b58fe-97f6-4cde-9078-6bb2dc49b95d/WT71-CodeSandbox.png"></a>

@@ -185,79 +187,4 @@

## Usage example StreamBuilder
As you can see now, increase() and decrease() methods are called directly within the UI component. However, output data is handle by a stream builder.
`JavaScript`
```javascript
const Counter = ({ bloc }) => (
<Fragment>
<button onClick={() => bloc.increase()}>+</button>
<button onClick={() => bloc.decrease()}>-</button>
<lable size="large" color="olive">
Count:
<StreamBuilder
initialData={0}
stream={bloc.counter}
builder={(snapshot) => <p>{snapshot.data}</p>}
/>
</lable>
</Fragment>
);
export default Counter;
```
`TypeScript`
```javascript
interface CounterProps {
bloc: {
increase: () => void,
decrease: () => void,
counter: number,
};
}
const Counter: React.FC<CounterProps> = ({ bloc }) => (
<React.Fragment>
<button onClick={() => bloc.increase()}>+</button>
<button onClick={() => bloc.decrease()}>-</button>
<lable size="large" color="olive">
Count:
<StreamBuilder
initialData={0}
stream={bloc.counter}
builder={(snapshot) => <p>{snapshot.data}</p>}
/>
</lable>
</React.Fragment>
);
export default Counter;
```
In the App file, the Bloc is initialized using the CounterBloc class. Thus, the Counter component is used by passing the Bloc as a prop.
```javascript
const App = () => {
const bloc = new CounterBloc();
useEffect(() => {
return () => {
bloc.dispose();
};
}, []);
return (
<div>
<Counter bloc={bloc} />
</div>
);
};
export default App;
```
## Authors
- [@blencm](https://www.github.com/blencm)