Skip to content

Commit 4a30b9b

Browse files
committed
Updating Jails for v4
1 parent 6653a19 commit 4a30b9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+277
-277
lines changed

_sidebar.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
- [Events](events.md)
1515
- [Pub/Sub](pubsub.md)
1616
- [Expose/Get](expose-get.md)
17-
- [Props](props.md)
1817
- [Dependency Injection](dependencies.md)
1918

2019
- Template System
@@ -32,7 +31,4 @@
3231
- [Introduction](store.md)
3332

3433
- Packages
35-
- [Introduction](packages.md)
36-
37-
- Examples
38-
- [Introduction](examples.md)
34+
- [Introduction](packages.md)

dependencies.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ The **DI** system can be used to share singleton instances between components, a
77
You can even make your components more abstract by making them behave accordandly with dependencies they receive, like a validation component that can expect a set of functions for validations which can vary from one project to another.
88

99
*home.js*
10+
1011
```js
1112
import jails from 'jails-js'
1213
import * as validation from 'components/validation'
1314
import validators from 'helpers/validators'
1415

1516
const dependencies = {
16-
injection :{
17-
validators
18-
}
17+
validators
1918
}
2019

2120
jails.register('validation', validation, dependencies)
@@ -27,11 +26,11 @@ jails.start()
2726
*components/validation.js*
2827

2928
```js
30-
export default ({ main, injection }) => {
29+
export default function validation ({ main, injection }) {
3130

3231
const {validators} = injection
3332

34-
main(() => [
33+
main( _ => [
3534
// ... Do UI validations using validators
3635
])
3736
}

elm.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ jails.register('my-component', mycomponent)
2727

2828
```js
2929

30-
export default ({ main, elm }) => {
30+
export default function mycomponent ({ main, elm }) {
3131

32-
main(() => [
32+
main( _ => [
3333
whoami
3434
])
3535

events.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ Events are a powerful tool to sending messages from children to parent nodes, it
88
A function helper to add event listener that support `event delegation`.
99

1010
```js
11-
export default ({ main }) => {
11+
export default function mycomponent ({ main }) {
1212

13-
main(() => [
13+
main( _ => [
1414
events
1515
])
1616

1717
const events = ({ on }) => {
1818
on('click', componentClick)
19-
on('click', {'a':linkClick})
19+
on('click', 'a', linkClick)
2020
}
2121

2222
const componentClick = (event) => {
2323
console.log( 'Clicking in the component area', event.target )
2424
}
2525

26-
const linkClick = event => {
26+
const linkClick = (event) => {
2727
console.log( 'Clicking in a child link element', event.target )
2828
}
2929
}
@@ -39,7 +39,7 @@ Use that when possible to make the component function definition cleaner.
3939
A helper that removes a event listener.
4040

4141
```js
42-
export default ({ main, off }) => {
42+
export default function mycomponent ({ main, off }) {
4343

4444
main(() => [
4545
events
@@ -69,9 +69,9 @@ The first parameter is any string you want, the second parameter optional data t
6969
**Parent Component**
7070

7171
```js
72-
export default ({ main }) => {
72+
export default function parentcomponent ({ main }) {
7373

74-
main(() => [
74+
main( _ => [
7575
events
7676
])
7777

@@ -88,9 +88,9 @@ export default ({ main }) => {
8888
**Child Component**
8989

9090
```js
91-
export default ({ main, emit }) => {
91+
export default function childcomponent ({ main, emit }){
9292

93-
main(() => [
93+
main( _ => [
9494
events
9595
])
9696

expose-get.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ All component's functions are private by default, in order to have access to a c
1010
*components/button/index.js*
1111

1212
```js
13-
export default ({ main, elm }) => {
13+
export default function button ({ main, elm }) {
1414

15-
main(()=>[
15+
main( _ => [
1616
exposing
1717
])
1818

1919
// Making changeColor() public
20-
const exposing = ({ expose }) =>
21-
expose( {changeColor} )
22-
23-
const changeColor = ( color ) =>
20+
const exposing = ({ expose }) => {
21+
expose({ changeColor })
22+
}
23+
24+
const changeColor = ( color ) => {
2425
elm.style.backgroundColor = color
26+
}
2527
}
2628
```
2729

@@ -36,11 +38,11 @@ The example below is a parent component of the component created in the previous
3638
*components/parentOfButtonCP/index.js*
3739

3840
```js
39-
export default ({ main }) => {
41+
export default function parentOfButton ({ main }) {
4042

4143
const buttonComponents = get('button')
4244

43-
main(() => [
45+
main( _ => [
4446
changeButtonsColors
4547
])
4648

@@ -57,11 +59,11 @@ The default behavior is to find all components named as `button`, in the example
5759
If you need to specify which component you want to change, you can do so by passing a **CssSelector** as second parameter to get a specific component:
5860

5961
```js
60-
export default ({ main }) => {
62+
export default function parentComponent({ main }) {
6163

6264
const buttonComponents = get('button', '.with-this-class')
6365

64-
main(() => [
66+
main( _ => [
6567
changeButtonsColors
6668
])
6769

images/logo.png

10.2 KB
Loading

images/logo.svg

Lines changed: 12 additions & 20 deletions
Loading

installing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
Adding with `yarn` :
77
```
8-
yarn add jails-js
8+
yarn add jails-org/jails-js#@next
99
```
1010

1111
Installing with `npm` :

main.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Every Jails components are a high level function that gets a set of helpers that
77
**The `main` function is used to setup your component definitions when it's mounted.**
88

99
```js
10-
export default ({ main }) => {
10+
export default function ({ main }) {
1111

12-
main(() => [
12+
main( _ => [
1313
log
1414
])
1515

@@ -28,9 +28,9 @@ You can compose different behaviors/logic with another component to separate dif
2828
```js
2929
import trackings from './tracking'
3030

31-
export default ({ main }) => {
31+
export default function tracking ({ main }) {
3232

33-
main(() => [
33+
main( _ => [
3434
trackings,
3535
log
3636
])

packages.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,4 @@ These modules can be installed and imported on your application just like any ot
2020
"jails.packages":"jails-org/packages"
2121
}
2222
}
23-
```
24-
25-
*my-app.js*
26-
27-
```js
28-
import jails from 'jails-js'
29-
import logger from 'jails.packages/logger'
30-
31-
jails.use( logger() ).start()
32-
```
23+
```

0 commit comments

Comments
 (0)