Skip to content

Commit

Permalink
Merge pull request #31 from lorengreenfield/prevent-geb-ssr
Browse files Browse the repository at this point in the history
Prevent geb from running during SSR
  • Loading branch information
lorengreenfield authored Jul 17, 2017
2 parents 757da2a + 2853d5d commit fea0bf0
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 59 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ geb.on('fieldUpdate', newValue => {
value: newValue
}
}, {
deepMerge: true
deepMerge: false//deep merging on by default, set to false o overwrite whole objects without merging
})
});

Expand Down
62 changes: 37 additions & 25 deletions dist/halfcab.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,49 @@ var events = ee({});

function eventEmitter(){

function broadcast(eventName, eventObject){
var noop = () => {};

//Set a break point on the following line to monitor all events being broadcast
console.log('Event broadcast: '+ eventName);
events.emit(eventName, eventObject);
}
if(typeof window !== 'undefined'){
function broadcast(eventName, eventObject){

function on(eventName, cb){
//Set a break point on the following line to monitor all events being broadcast
console.log('Event broadcast: '+ eventName);
events.emit(eventName, eventObject);
}

//Set a break point on the following line to monitor all events being listened to
events.on(eventName, cb);
}
function on(eventName, cb){

function once(eventName, cb){
//Set a break point on the following line to monitor all events being listened to
events.on(eventName, cb);
}

//Set a break point on the following line to monitor all events being listened to just once
events.once(eventName, cb);
}
function once(eventName, cb){

function off(eventName, listenerFunction){
//Set a break point on the following line to monitor all events being listened to just once
events.once(eventName, cb);
}

//Set a break point on the following line to monitor all events being unlistened to
events.off(eventName, listenerFunction);
}
function off(eventName, listenerFunction){

//Set a break point on the following line to monitor all events being unlistened to
events.off(eventName, listenerFunction);
}

return {
broadcast: broadcast,
on: on,
once: once,
off: off
return {
broadcast: broadcast,
on: on,
once: once,
off: off
}
}else{
return {
broadcast: noop,
on: noop,
once: noop,
off: noop
}
}

}

var eventEmitter$1 = new eventEmitter();
Expand Down Expand Up @@ -120,10 +132,10 @@ function setMaxStates(num){

function updateState(updateObject, options){

if(options && options.deepMerge){
states.push(Object.assign({}, merge(getLatestState(), updateObject)));
}else{
if(options && options.deepMerge === false){
states.push(Object.assign({}, getLatestState(), updateObject));
}else{
states.push(Object.assign({}, merge(getLatestState(), updateObject)));
}
if(states.length > maxStates){
states.shift();
Expand Down
70 changes: 41 additions & 29 deletions eventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,49 @@ var events = ee({});

function eventEmitter(){

function broadcast(eventName, eventObject){

//Set a break point on the following line to monitor all events being broadcast
console.log('Event broadcast: '+ eventName);
events.emit(eventName, eventObject);
}

function on(eventName, cb){

//Set a break point on the following line to monitor all events being listened to
events.on(eventName, cb);
var noop = () => {};

if(typeof window !== 'undefined'){
function broadcast(eventName, eventObject){

//Set a break point on the following line to monitor all events being broadcast
console.log('Event broadcast: '+ eventName);
events.emit(eventName, eventObject);
}

function on(eventName, cb){

//Set a break point on the following line to monitor all events being listened to
events.on(eventName, cb);
}

function once(eventName, cb){

//Set a break point on the following line to monitor all events being listened to just once
events.once(eventName, cb);
}

function off(eventName, listenerFunction){

//Set a break point on the following line to monitor all events being unlistened to
events.off(eventName, listenerFunction);
}

return {
broadcast: broadcast,
on: on,
once: once,
off: off
}
}else{
return {
broadcast: noop,
on: noop,
once: noop,
off: noop
}
}

function once(eventName, cb){

//Set a break point on the following line to monitor all events being listened to just once
events.once(eventName, cb);
}

function off(eventName, listenerFunction){

//Set a break point on the following line to monitor all events being unlistened to
events.off(eventName, listenerFunction);
}

return {
broadcast: broadcast,
on: on,
once: once,
off: off
}
}

export default new eventEmitter();
Expand Down
6 changes: 3 additions & 3 deletions halfcab.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ function setMaxStates(num){

function updateState(updateObject, options){

if(options && options.deepMerge){
states.push(Object.assign({}, merge(getLatestState(), updateObject)));
}else{
if(options && options.deepMerge === false){
states.push(Object.assign({}, getLatestState(), updateObject));
}else{
states.push(Object.assign({}, merge(getLatestState(), updateObject)));
}
if(states.length > maxStates){
states.shift();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "halfcab",
"version": "1.9.0",
"version": "2.0.0",
"description": "A simple universal JavaScript framework focused on making use of es2015 template strings to build components.",
"main": "dist/halfcab.js",
"module": "halfcab.js",
Expand Down

0 comments on commit fea0bf0

Please sign in to comment.