Browse Source

Added remove props handler

master
Anthony Hinsinger 5 years ago
parent
commit
3be69bcf4c
  1. 18
      index.js

18
index.js

@ -36,6 +36,11 @@ const typeDefs = gql`
permission: Int permission: Int
} }
type RemovedProperty {
id: String!
device: String!
}
interface Vector { interface Vector {
id: String! id: String!
name: String! name: String!
@ -127,6 +132,10 @@ const typeDefs = gql`
connected: Boolean connected: Boolean
} }
type RemovedDevice {
id: String!
}
type Message { type Message {
id: String id: String
device: Device! device: Device!
@ -180,6 +189,7 @@ const typeDefs = gql`
disconnected: Int disconnected: Int
newDevice: Device newDevice: Device
newProperty: Property newProperty: Property
removeProperty: RemovedProperty
newValue: Vector newValue: Vector
newMessage: Message newMessage: Message
} }
@ -210,6 +220,7 @@ indi
pubsub.publish(["NEW_DEVICE"], { newDevice: device }); pubsub.publish(["NEW_DEVICE"], { newDevice: device });
}) })
.on("newProperty", (property) => { .on("newProperty", (property) => {
console.log("new props");
if ( if (
property.getType() === Indi.PropertyType.Number || property.getType() === Indi.PropertyType.Number ||
property.getType() === Indi.PropertyType.Switch || property.getType() === Indi.PropertyType.Switch ||
@ -219,6 +230,10 @@ indi
pubsub.publish(["NEW_PROPERTY"], { newProperty: property }); pubsub.publish(["NEW_PROPERTY"], { newProperty: property });
} }
}) })
.on("removeProperty", (propname, devname) => {
console.log("remove props");
pubsub.publish(["REMOVE_PROPERTY"], { removeProperty: { id: propname, device: devname } });
})
.on("newNumber", (n) => { .on("newNumber", (n) => {
pubsub.publish(["NEW_VALUE"], { newValue: n }); pubsub.publish(["NEW_VALUE"], { newValue: n });
}) })
@ -342,6 +357,9 @@ const resolvers = {
newProperty: { newProperty: {
subscribe: () => pubsub.asyncIterator(["NEW_PROPERTY"]), subscribe: () => pubsub.asyncIterator(["NEW_PROPERTY"]),
}, },
removeProperty: {
subscribe: () => pubsub.asyncIterator(["REMOVE_PROPERTY"]),
},
newValue: { newValue: {
subscribe: () => pubsub.asyncIterator(["NEW_VALUE"]), subscribe: () => pubsub.asyncIterator(["NEW_VALUE"]),
}, },

Loading…
Cancel
Save