janhommes / o.js

o.js - client side oData lib.
https://janhommes.github.io/o.js/example/
MIT License
238 stars 57 forks source link

Wrap factory into a createClient function to allow scoped instances #34

Closed moander closed 3 years ago

moander commented 8 years ago
<script src="bower_components/q/q.js"></script>
<script src="bower_components/o.js/o.js"></script>

<script>

o().config({ endpoint: 'global' });

var x = o.createClient();
x().config({ endpoint: 'localX' });

var y = o.createClient({ endpoint: 'localY' });

console.log(o().oConfig.endpoint);
console.log(x().oConfig.endpoint);
console.log(y().oConfig.endpoint);

</script>

Output:

global
localX
localY
moander commented 8 years ago

Line 44 and 1571-1580 is my additions. The rest is just indentation ;)

janhommes commented 8 years ago

@moander Good idea! Can you please fix the test? Afterwards I can merge you pull-request.