Skip to content

Commit d933ce0

Browse files
committed
refactor(type-service): remove it from the this.rb object
If you need to use, import it
1 parent aa7cd14 commit d933ce0

File tree

5 files changed

+36
-31
lines changed

5 files changed

+36
-31
lines changed

README.md

+26-19
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ $ npm install @rapid-build-ui/rb-base
1313
* The view rendering engine [lit-html](https://polymer.github.io/lit-html/).
1414
* Imports:
1515
* guid-service.js
16+
* type-service.js
1617
* view-directives.js
1718
* Callbacks:
1819
* viewReady()
1920
* Creates this.rb object that contains a set of common helper objects:
2021
* this.rb.events
21-
* this.rb.type
2222
* this.rb.view
2323

2424

@@ -57,6 +57,7 @@ Executed once when view is ready and all its rb sub components views are ready.
5757
Use when you need to make sure elements are accessible in the shadow dom.
5858

5959

60+
6061
## Imports (optional)
6162

6263
### guid-service.js
@@ -65,8 +66,30 @@ Use when you need to make sure elements are accessible in the shadow dom.
6566

6667
```js
6768
// Example
68-
import guid from '../../rb-base/scripts/guid-service.js';
69-
const id = guid.create();
69+
import Guid from '../../rb-base/scripts/guid-service.js';
70+
const guid = Guid.create();
71+
```
72+
73+
74+
### type-service.js
75+
* Methods (**is.methods() :boolean**)
76+
* get(val) :string (returns val type)
77+
* is.array(val)
78+
* is.boolean(val)
79+
* is.function(val)
80+
* is.int(val)
81+
* is.null(val)
82+
* is.number(val)
83+
* is.object(val)
84+
* is.promise(val)
85+
* is.string(val)
86+
* is.stringArray(val)
87+
* is.undefined(val)
88+
89+
```js
90+
// Example
91+
import Type from '../../rb-base/scripts/type-service.js';
92+
const isString = Type.is.string('rapid');
7093
```
7194

7295

@@ -99,22 +122,6 @@ to be used in view.
99122
* emit(elm, 'event' [, { detail: any } ]) :boolean
100123

101124

102-
### this.rb.type
103-
* Methods (**is.methods() :boolean**)
104-
* get(val) :string (returns val type)
105-
* is.array(val)
106-
* is.boolean(val)
107-
* is.function(val)
108-
* is.int(val)
109-
* is.null(val)
110-
* is.number(val)
111-
* is.object(val)
112-
* is.promise(val)
113-
* is.string(val)
114-
* is.stringArray(val)
115-
* is.undefined(val)
116-
117-
118125
### this.rb.view
119126
* Properties
120127
* isReady :boolean (readonly, will be true when view is ready)

src/client/scripts/event-service.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
- this.rb.events.emit(elm, 'event' [, { detail: any } ]); :boolean
1313
********************************************************************************/
1414
import { emit } from '../../../skatejs/dist/esnext/emit.js';
15-
import guid from './guid-service.js';
15+
import Guid from './guid-service.js';
1616

1717
/* Event Helpers
1818
****************/
@@ -24,7 +24,7 @@ const EventHelper = {
2424
},
2525
_getSpace(target, space = null) { // :string
2626
if (target.dataset.rbEvent) return target.dataset.rbEvent;
27-
if (!space) space = guid.create(5);
27+
if (!space) space = Guid.create(5);
2828
target.dataset.rbEvent = space;
2929
return space;
3030
},
@@ -99,7 +99,7 @@ const EventHelper = {
9999
return EventHelper.getCallbackName.call(this, callback.func);
100100

101101
if (!callback.name) // for anonymous functions (set name for removeAll())
102-
Object.defineProperty(callback, 'name', { value: guid.create(5) });
102+
Object.defineProperty(callback, 'name', { value: Guid.create(5) });
103103

104104
// bound functions are prefixed with 'bound '
105105
return callback.name.replace(/^bound /, '');

src/client/scripts/guid-service.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* GUID SERVICE
33
****************************************
44
* HOW TO USE
5-
- import guid from './guid-service.js';
5+
- import Guid from './guid-service.js';
66
* API
7-
- guid.create(maxLength = 12); :string
7+
- Guid.create(maxLength = 12); :string
88
****************************************/
99
const GuidService = {
1010
create(maxLength = 12) { // :string (sometimes returns maxLength - 1 chars)

src/client/scripts/rb-base.js

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import { props, withComponent } from '../../../skatejs/dist/esnext/index.js';
55
import { html, render } from '../../../lit-html/lit-html.js';
66
import EventService from './event-service.js';
7-
import TypeService from './type-service.js';
87
import ViewService from './view-service.js';
98

109
/* RB Base Class
@@ -16,7 +15,6 @@ const RbBase = (Base = HTMLElement) => class extends withComponent(Base) {
1615
super();
1716
this.rb = {
1817
events: EventService.call(this),
19-
type: TypeService,
2018
view: ViewService.call(this)
2119
}
2220
}

src/client/scripts/type-service.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/***********************************************************
1+
/****************************************
22
* TYPE SERVICE
3-
***********************************************************
3+
****************************************
44
* HOW TO USE
5-
- import TypeService from './type-service.js';
6-
- this.rb.type = TypeService; :object (set in constructor)
7-
***********************************************************/
5+
- import Type from './type-service.js';
6+
- Type = TypeService; :object
7+
****************************************/
88
const TypeService = {
99
/* Return Type as String
1010
************************/

0 commit comments

Comments
 (0)